You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
ikvm-native
libgc
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
SMDiagnostics
System
System.Activities
System.Activities.Core.Presentation
System.Activities.DurableInstancing
System.Activities.Presentation
System.ComponentModel.DataAnnotations
System.Configuration
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.IdentityModel
System.IdentityModel.Selectors
System.Net
System.Numerics
System.Runtime.Caching
System.Runtime.DurableInstancing
System.Runtime.Serialization
System.ServiceModel
InternalApis
Serialization
System
Collections
ServiceModel
Activation
Administration
Channels
ComIntegration
Configuration
Description
Diagnostics
Dispatcher
MsmqIntegration
PeerResolvers
Security
Tokens
AcceleratedTokenAuthenticator.cs
AcceleratedTokenProvider.cs
AcceleratedTokenProviderState.cs
AcceptorSessionSymmetricMessageSecurityProtocol.cs
AcceptorSessionSymmetricTransportSecurityProtocol.cs
ApplySecurityAndSendAsyncResult.cs
AsymmetricSecurityProtocol.cs
AsymmetricSecurityProtocolFactory.cs
BasicSecurityProfileVersion.cs
BinaryNegotiation.cs
ChannelProtectionRequirements.cs
ClientCredentialsSecurityTokenManager.cs
CryptoHelper.cs
DataProtectionSecurityStateEncoder.cs
DecryptedHeader.cs
DelegatingHeader.cs
DerivedKeyCachingSecurityTokenSerializer.cs
DispatchContext.cs
DuplexSecurityProtocolFactory.cs
EncryptedData.cs
EncryptedHeader.cs
EncryptedHeaderXml.cs
ExpiredSecurityTokenException.cs
FederatedSecurityTokenManager.cs
HttpDigestClientCredential.cs
IAcceptorSecuritySessionProtocol.cs
IChannelSecureConversationSessionSettings.cs
IEndpointIdentityProvider.cs
IInitiatorSecuritySessionProtocol.cs
IListenerSecureConversationSessionSettings.cs
ISecureConversationSession.cs
ISecurityCommunicationObject.cs
ISecuritySession.cs
IWSTrust13AsyncContract.cs
IWSTrust13SyncContract.cs
IWSTrustChannelContract.cs
IWSTrustContract.cs
IWSTrustFeb2005AsyncContract.cs
IWSTrustFeb2005SyncContract.cs
IdentityModelServiceAuthorizationManager.cs
IdentityVerifier.cs
ImpersonateOnSerializingReplyMessageProperty.cs
ImpersonatingMessage.cs
InMemoryNonceCache.cs
InfoCardChannelParameter.cs
InfoCardHelper.cs
InfocardInteractiveChannelInitializer.cs
InitiatorSessionSymmetricMessageSecurityProtocol.cs
InitiatorSessionSymmetricTransportSecurityProtocol.cs
IssuanceTokenProviderBase.cs
IssuanceTokenProviderState.cs
IssuedTokenClientCredential.cs
IssuedTokenServiceCredential.cs
IssuedTokensHeader.cs
LaxModeSecurityHeaderElementInferenceEngine.cs
LaxTimestampFirstModeSecurityHeaderElementInferenceEngine.cs
LaxTimestampLastModeSecurityHeaderElementInferenceEngine.cs
MessagePartProtectionMode.cs
MessagePartSpecification.cs
MessageProtectionOrder.cs
MessageSecurityException.cs
MessageSecurityProtocol.cs
MessageSecurityProtocolFactory.cs
MessageSecurityTokenVersion.cs
Namespaces.cs
NegotiationTokenAuthenticator.cs
NegotiationTokenAuthenticatorState.cs
NegotiationTokenAuthenticatorStateCache.cs
NegotiationTokenProvider.cs
NonceCache.cs
NonceToken.cs
PeerCredential.cs
Psha1DerivedKeyGeneratorHelper.cs
ReceiveMessageAndVerifySecurityAsyncResultBase.cs
ReceiveSecurityHeader.cs
ReceiveSecurityHeaderBindingModes.cs
ReceiveSecurityHeaderElementCategory.cs
ReceiveSecurityHeaderElementManager.cs
ReceiveSecurityHeaderEntry.cs
RequestSecurityToken.cs
RequestSecurityTokenResponse.cs
RequestSecurityTokenResponseCollection.cs
RoleProviderPrincipal.cs
ScopedMessagePartSpecification.cs
SctClaimDictionary.cs
SctClaimSerializer.cs
SctClaimsHandler.cs
SecureConversationDriver.cs
SecureConversationServiceCredential.cs
SecureConversationVersion.cs
SecurityAccessDeniedException.cs
SecurityAlgorithmSuite.cs
SecurityAppliedMessage.cs
SecurityChannel.cs
SecurityContextTokenCache.cs
SecurityCredentialsManager.cs
SecurityHeader.cs
SecurityHeaderElementInferenceEngine.cs
SecurityHeaderTokenResolver.cs
SecurityKeyEntropyMode.cs
SecurityListenerSettingsLifetimeManager.cs
SecurityMessageProperty.cs
SecurityNegotiationConstants.cs
SecurityNegotiationException.cs
SecurityPolicyVersion.cs
SecurityProtocol.cs
SecurityProtocolCorrelationState.cs
SecurityProtocolFactory.cs
SecuritySessionClientSettings.cs.REMOVED.git-id
SecuritySessionFilter.cs
SecuritySessionOperation.cs
SecuritySessionSecurityTokenAuthenticator.cs
SecuritySessionSecurityTokenProvider.cs
SecuritySessionServerSettings.cs.REMOVED.git-id
SecurityStandardsManager.cs
SecurityStateEncoder.cs
SecurityTimestamp.cs
SecurityTokenAttachmentMode.cs
SecurityTokenAuthenticatorAdapter.cs
SecurityTokenParametersEnumerable.cs
SecurityTokenSpecification.cs
SecurityUtils.cs.REMOVED.git-id
SecurityUtilsEx.cs
SecurityVerifiedMessage.cs
SecurityVersion.cs
SendSecurityHeader.cs
SendSecurityHeaderElement.cs
SendSecurityHeaderElementContainer.cs
ServiceCredentialsSecurityTokenManager.cs
SessionKeyExpiredException.cs
SessionSymmetricMessageSecurityProtocolFactory.cs
SessionSymmetricTransportSecurityProtocolFactory.cs
SignatureConfirmationElement.cs
SignatureConfirmations.cs
SignatureTargetIdManager.cs
SimpleSecurityTokenProvider.cs
SpnegoTokenAuthenticator.cs
SpnegoTokenProvider.cs
SspiNegotiationTokenAuthenticator.cs
SspiNegotiationTokenAuthenticatorState.cs
SspiNegotiationTokenProvider.cs
SspiNegotiationTokenProviderState.cs
SspiSecurityTokenProvider.cs
StrictModeSecurityHeaderElementInferenceEngine.cs
SupportingTokenAuthenticatorSpecification.cs
SupportingTokenProviderSpecification.cs
SupportingTokenSpecification.cs
SymmetricSecurityProtocol.cs
SymmetricSecurityProtocolFactory.cs
TimeBoundedCache.cs
TlsSspiNegotiation.cs
TlsnegoTokenAuthenticator.cs
TlsnegoTokenProvider.cs
TransportSecurityProtocol.cs
TransportSecurityProtocolFactory.cs
TrustDriver.cs
TrustVersion.cs
UserNamePasswordClientCredential.cs
UserNamePasswordServiceCredential.cs
UserNamePasswordValidationMode.cs
WSSecureConversation.cs
WSSecureConversationDec2005.cs
WSSecureConversationFeb2005.cs
WSSecurityJan2004.cs
WSSecurityOneDotOneReceiveSecurityHeader.cs
WSSecurityOneDotOneSendSecurityHeader.cs
WSSecurityOneDotZeroReceiveSecurityHeader.cs
WSSecurityOneDotZeroSendSecurityHeader.cs
WSSecurityPolicy.cs.REMOVED.git-id
WSSecurityPolicy11.cs
WSSecurityPolicy12.cs
WSSecurityTokenSerializer.cs
WSSecurityXXX2005.cs
WSTrust.cs
WSTrustChannel.cs
WSTrustChannelFactory.cs
WSTrustDec2005.cs
WSTrustFeb2005.cs
WSTrustRequestBodyWriter.cs
WSTrustRequestProcessingErrorEventArgs.cs
WSTrustResponseBodyWriter.cs
WSTrustServiceContract.cs.REMOVED.git-id
WSTrustServiceContractConstants.cs
WSTrustServiceHost.cs
WSUtilitySpecificationVersion.cs
WindowsClientCredential.cs
WindowsServiceCredential.cs
WindowsSspiNegotiation.cs
WrappedRsaSecurityTokenAuthenticator.cs
WrappedSaml11SecurityTokenAuthenticator.cs
WrappedSaml2SecurityTokenAuthenticator.cs
WrappedSamlSecurityTokenAuthenticator.cs
WrappedSessionSecurityTokenAuthenticator.cs
WrappedTokenCache.cs
WrappedUserNameSecurityTokenAuthenticator.cs
WrappedX509SecurityTokenAuthenticator.cs
WrapperSecurityCommunicationObject.cs
WsKeyInfoSerializer.cs
WsSecurityTokenSerializerAdapter.cs
X509CertificateInitiatorClientCredential.cs
X509CertificateInitiatorServiceCredential.cs
X509CertificateRecipientClientCredential.cs
X509CertificateRecipientServiceCredential.cs
X509CertificateValidationMode.cs
X509ClientCertificateAuthentication.cs
X509PeerCertificateAuthentication.cs
X509ServiceCertificateAuthentication.cs
XmlHelper.cs
Syndication
Transactions
XamlIntegration
ActionMismatchAddressingException.cs
ActionNotSupportedException.cs
AddressAccessDeniedException.cs
AddressAlreadyInUseException.cs
AddressFilterMode.cs
AppContextDefaultValues.Default.cs
AuditLevel.cs
AuditLogLocation.cs
BasicHttpBinding.cs
BasicHttpContextBinding.cs
BasicHttpMessageCredentialType.cs
BasicHttpMessageSecurity.cs
BasicHttpSecurity.cs
BasicHttpSecurityMode.cs
BasicHttpsBinding.cs
BasicHttpsSecurity.cs
BasicHttpsSecurityMode.cs
CacheSetting.cs
CallbackBehaviorAttribute.cs
ChannelFactory.cs
ChannelFactoryRefCache.cs
ChannelTerminatedException.cs
ClientBase.cs
CommunicationException.cs
CommunicationObjectAbortedException.cs
CommunicationObjectFaultedException.cs
CommunicationState.cs
ConcurrencyMode.cs
ConfigurationEndpointTrait.cs
DXD.cs
DataContractFormatAttribute.cs
DeadLetterQueue.cs
DeliveryRequirementsAttribute.cs
DnsEndpointIdentity.cs
DuplexChannelFactory.cs
DuplexClientBase.cs
EmptyArray.cs
EndpointAddress.cs
EndpointAddress10.cs
EndpointAddressAugust2004.cs
EndpointIdentity.cs
EndpointNotFoundException.cs
EndpointTrait.cs
EnvelopeVersion.cs
ExceptionDetail.cs
ExceptionMapper.cs
ExtensionCollection.cs
FaultCode.cs
FaultCodeConstants.cs
FaultContractAttribute.cs
FaultException.cs
FaultImportOptions.cs
FaultReason.cs
FaultReasonText.cs
FederatedMessageSecurityOverHttp.cs
GeneralEndpointIdentity.cs
HostnameComparisonMode.cs
HttpBindingBase.cs
HttpClientCredentialType.cs
HttpProxyCredentialType.cs
HttpTransportSecurity.cs
IChannelBaseProxy.cs
IClientChannel.cs
ICommunicationObject.cs
IContextChannel.cs
IContextSessionProvider.cs
IDefaultCommunicationTimeouts.cs
IDuplexContextChannel.cs
IExtensibleObject.cs
IExtension.cs
IExtensionCollection.cs
IOnlineStatus.cs
IOperationContractAttributeProvider.cs
IServiceChannel.cs
ImpersonationOption.cs
InstanceContext.cs
InstanceContextMode.cs
InvalidMessageContractException.cs
KeyedByTypeCollection.cs
LocalAppContextSwitches.cs
MessageBodyMemberAttribute.cs
MessageContractAttribute.cs
MessageContractMemberAttribute.cs
MessageCredentialType.cs
MessageHeaderArrayAttribute.cs
MessageHeaderAttribute.cs
MessageHeaderException.cs
MessageHeaderT.cs
MessageParameterAttribute.cs
MessagePropertyAttribute.cs
MessageSecurityOverHttp.cs
MessageSecurityOverMsmq.cs
MessageSecurityOverTcp.cs
MessageSecurityVersion.cs
MostlySingletonList.cs
MsmqAuthenticationMode.cs
MsmqBindingBase.cs
MsmqEncryptionAlgorithm.cs
MsmqException.cs
MsmqPoisonMessageException.cs
MsmqSecureHashAlgorithm.cs
MsmqTransportSecurity.cs
MustUnderstandSoapException.cs
NamedPipeTransportSecurity.cs
NetHttpBinding.cs
NetHttpMessageEncoding.cs
NetHttpMessageEncodingHelper.cs
NetHttpsBinding.cs
NetMsmqBinding.cs
NetMsmqSecurity.cs
NetMsmqSecurityMode.cs
NetNamedPipeBinding.cs
NetNamedPipeSecurity.cs
NetNamedPipeSecurityMode.cs
NetPeerTcpBinding.cs
NetTcpBinding.cs
NetTcpContextBinding.cs
NetTcpSecurity.cs
NonDualMessageSecurityOverHttp.cs
OSEnvironmentHelper.cs
OSVersion.cs
OperationBehaviorAttribute.cs
OperationContext.cs
OperationContextScope.cs
OperationContractAttribute.cs
OperationFormatStyle.cs
OperationFormatUse.cs
PeerHopCountAttribute.cs
PeerMessageOrigination.cs
PeerMessagePropagation.cs
PeerMessagePropagationFilter.cs
PeerNode.cs
PeerNodeAddress.cs
PeerResolver.cs
PeerSecuritySettings.cs
PeerTransportCredentialType.cs
PeerTransportSecuritySettings.cs
PoisonMessageException.cs
Pool.cs
ProgrammaticEndpointTrait.cs
ProtocolException.cs
QueueTransferProtocol.cs
QueuedDeliveryRequirementsMode.cs
QuotaExceededException.cs
ReceiveContextEnabledAttribute.cs
ReceiveErrorHandling.cs
ReleaseInstanceMode.cs
ReliableMessagingVersion.cs
ReliableSession.cs
RsaEndpointIdentity.cs
SecurityMode.cs
ServerTooBusyException.cs
ServiceActivationException.cs
ServiceAuthenticationManager.cs
ServiceAuthorizationManager.cs
ServiceBehaviorAttribute.cs
ServiceChannelManager.cs
ServiceConfiguration.cs
ServiceContractAttribute.cs
ServiceDefaults.cs
ServiceEndpointTrait.cs
ServiceHost.cs
ServiceKnownTypeAttribute.cs
ServiceModelAppSettings.cs
ServiceModelAttributeTargets.cs
ServiceModelDictionary.cs
ServiceModelStrings.cs
ServiceModelStringsVersion1.cs
ServiceSecurityContext.cs
SessionMode.cs
SpnEndpointIdentity.cs
StringUtil.cs
SynchronizedCollection.cs
SynchronizedDisposablePool.cs
SynchronizedKeyedCollection.cs
SynchronizedReadOnlyCollection.cs
TcpClientCredentialType.cs
TcpTransportSecurity.cs
ThreadTrace.cs
TimeSpanHelper.cs
TransactionFlowAttribute.cs
TransactionFlowOption.cs
TransactionProtocol.cs
TransferMode.cs
UnifiedSecurityMode.cs
UnknownMessageReceivedEventArgs.cs
UpnEndpointIdentity.cs
UriSchemeKeyedCollection.cs
WS2007FederationHttpBinding.cs
WS2007HttpBinding.cs
WSAddressing10ProblemHeaderQNameFault.cs
WSDualHttpBinding.cs
WSDualHttpSecurity.cs
WSDualHttpSecurityMode.cs
WSFederationHttpBinding.cs
WSFederationHttpSecurity.cs
WSFederationHttpSecurityMode.cs
WSHttpBinding.cs
WSHttpBindingBase.cs
WSHttpContextBinding.cs
WSHttpSecurity.cs
WSMessageEncoding.cs
WrappedDispatcherException.cs
X509CertificateEndpointIdentity.cs
XD.cs.REMOVED.git-id
XPathMessageQuery.cs
XmlBuffer.cs
XmlSerializerFormatAttribute.cs
XmlUtil.cs
UriTemplate.cs
UriTemplateCompoundPathSegment.cs
UriTemplateEquivalenceComparer.cs
UriTemplateHelpers.cs
UriTemplateLiteralPathSegment.cs
UriTemplateLiteralQueryValue.cs
UriTemplateMatch.cs
UriTemplateMatchException.cs
UriTemplatePartType.cs
UriTemplatePathPartiallyEquivalentSet.cs
UriTemplatePathSegment.cs
UriTemplateQueryValue.cs
UriTemplateTable.cs
UriTemplateTableMatchCandidate.cs
UriTemplateTrieIntraNodeLocation.cs
UriTemplateTrieLocation.cs
UriTemplateTrieNode.cs
UriTemplateVariablePathSegment.cs
UriTemplateVariableQueryValue.cs
AssemblyInfo.cs
System.ServiceModel.txt.REMOVED.git-id
TD.Designer.cs.REMOVED.git-id
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
System.Web.ApplicationServices
System.Web.DataVisualization
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.WorkflowServices
System.Xaml.Hosting
System.Xml
System.Xml.Linq
XamlBuildTask
mscorlib
LICENSE.txt
PATENTS.TXT
README.Mono.md
README.md
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
nunit24
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
703 lines
28 KiB
C#
703 lines
28 KiB
C#
![]() |
//------------------------------------------------------------
|
||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
//------------------------------------------------------------
|
||
|
|
||
|
namespace System.ServiceModel.Security
|
||
|
{
|
||
|
using System;
|
||
|
using System.ServiceModel.Channels;
|
||
|
using System.ServiceModel;
|
||
|
using System.Xml;
|
||
|
using System.Security.Cryptography;
|
||
|
using System.Security.Cryptography.Xml;
|
||
|
using System.Runtime.Serialization;
|
||
|
using System.Xml.Serialization;
|
||
|
using System.Xml.Schema;
|
||
|
using System.Security.Principal;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Collections.ObjectModel;
|
||
|
using System.IdentityModel.Claims;
|
||
|
using System.IdentityModel.Policy;
|
||
|
using System.IdentityModel.Tokens;
|
||
|
using System.IdentityModel.Selectors;
|
||
|
using System.ServiceModel.Security.Tokens;
|
||
|
using System.IO;
|
||
|
using System.ServiceModel.Security;
|
||
|
|
||
|
using Psha1DerivedKeyGenerator = System.IdentityModel.Psha1DerivedKeyGenerator;
|
||
|
using System.ServiceModel.Dispatcher;
|
||
|
|
||
|
class RequestSecurityTokenResponse : BodyWriter
|
||
|
{
|
||
|
static int minSaneKeySizeInBits = 8 * 8; // 8 Bytes.
|
||
|
static int maxSaneKeySizeInBits = (16 * 1024) * 8; // 16 K
|
||
|
|
||
|
SecurityStandardsManager standardsManager;
|
||
|
string context;
|
||
|
int keySize;
|
||
|
bool computeKey;
|
||
|
string tokenType;
|
||
|
SecurityKeyIdentifierClause requestedAttachedReference;
|
||
|
SecurityKeyIdentifierClause requestedUnattachedReference;
|
||
|
SecurityToken issuedToken;
|
||
|
SecurityToken proofToken;
|
||
|
SecurityToken entropyToken;
|
||
|
BinaryNegotiation negotiationData;
|
||
|
XmlElement rstrXml;
|
||
|
DateTime effectiveTime;
|
||
|
DateTime expirationTime;
|
||
|
bool isLifetimeSet;
|
||
|
byte[] authenticator;
|
||
|
bool isReceiver;
|
||
|
bool isReadOnly;
|
||
|
byte[] cachedWriteBuffer;
|
||
|
int cachedWriteBufferLength;
|
||
|
bool isRequestedTokenClosed;
|
||
|
object appliesTo;
|
||
|
XmlObjectSerializer appliesToSerializer;
|
||
|
Type appliesToType;
|
||
|
Object thisLock = new Object();
|
||
|
System.IdentityModel.XmlBuffer issuedTokenBuffer;
|
||
|
|
||
|
public RequestSecurityTokenResponse()
|
||
|
: this(SecurityStandardsManager.DefaultInstance)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public RequestSecurityTokenResponse(MessageSecurityVersion messageSecurityVersion, SecurityTokenSerializer securityTokenSerializer)
|
||
|
: this(SecurityUtils.CreateSecurityStandardsManager(messageSecurityVersion, securityTokenSerializer))
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public RequestSecurityTokenResponse(XmlElement requestSecurityTokenResponseXml,
|
||
|
string context,
|
||
|
string tokenType,
|
||
|
int keySize,
|
||
|
SecurityKeyIdentifierClause requestedAttachedReference,
|
||
|
SecurityKeyIdentifierClause requestedUnattachedReference,
|
||
|
bool computeKey,
|
||
|
DateTime validFrom,
|
||
|
DateTime validTo,
|
||
|
bool isRequestedTokenClosed)
|
||
|
: this(SecurityStandardsManager.DefaultInstance,
|
||
|
requestSecurityTokenResponseXml,
|
||
|
context,
|
||
|
tokenType,
|
||
|
keySize,
|
||
|
requestedAttachedReference,
|
||
|
requestedUnattachedReference,
|
||
|
computeKey,
|
||
|
validFrom,
|
||
|
validTo,
|
||
|
isRequestedTokenClosed,
|
||
|
null)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public RequestSecurityTokenResponse(MessageSecurityVersion messageSecurityVersion,
|
||
|
SecurityTokenSerializer securityTokenSerializer,
|
||
|
XmlElement requestSecurityTokenResponseXml,
|
||
|
string context,
|
||
|
string tokenType,
|
||
|
int keySize,
|
||
|
SecurityKeyIdentifierClause requestedAttachedReference,
|
||
|
SecurityKeyIdentifierClause requestedUnattachedReference,
|
||
|
bool computeKey,
|
||
|
DateTime validFrom,
|
||
|
DateTime validTo,
|
||
|
bool isRequestedTokenClosed)
|
||
|
: this(SecurityUtils.CreateSecurityStandardsManager(messageSecurityVersion, securityTokenSerializer),
|
||
|
requestSecurityTokenResponseXml,
|
||
|
context,
|
||
|
tokenType,
|
||
|
keySize,
|
||
|
requestedAttachedReference,
|
||
|
requestedUnattachedReference,
|
||
|
computeKey,
|
||
|
validFrom,
|
||
|
validTo,
|
||
|
isRequestedTokenClosed,
|
||
|
null)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
internal RequestSecurityTokenResponse(SecurityStandardsManager standardsManager)
|
||
|
: base(true)
|
||
|
{
|
||
|
if (standardsManager == null)
|
||
|
{
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("standardsManager"));
|
||
|
}
|
||
|
this.standardsManager = standardsManager;
|
||
|
effectiveTime = SecurityUtils.MinUtcDateTime;
|
||
|
expirationTime = SecurityUtils.MaxUtcDateTime;
|
||
|
isRequestedTokenClosed = false;
|
||
|
this.isLifetimeSet = false;
|
||
|
this.isReceiver = false;
|
||
|
this.isReadOnly = false;
|
||
|
}
|
||
|
|
||
|
internal RequestSecurityTokenResponse(SecurityStandardsManager standardsManager,
|
||
|
XmlElement rstrXml,
|
||
|
string context,
|
||
|
string tokenType,
|
||
|
int keySize,
|
||
|
SecurityKeyIdentifierClause requestedAttachedReference,
|
||
|
SecurityKeyIdentifierClause requestedUnattachedReference,
|
||
|
bool computeKey,
|
||
|
DateTime validFrom,
|
||
|
DateTime validTo,
|
||
|
bool isRequestedTokenClosed,
|
||
|
System.IdentityModel.XmlBuffer issuedTokenBuffer)
|
||
|
: base(true)
|
||
|
{
|
||
|
if (standardsManager == null)
|
||
|
{
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("standardsManager"));
|
||
|
}
|
||
|
this.standardsManager = standardsManager;
|
||
|
if (rstrXml == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("rstrXml");
|
||
|
this.rstrXml = rstrXml;
|
||
|
this.context = context;
|
||
|
this.tokenType = tokenType;
|
||
|
this.keySize = keySize;
|
||
|
this.requestedAttachedReference = requestedAttachedReference;
|
||
|
this.requestedUnattachedReference = requestedUnattachedReference;
|
||
|
this.computeKey = computeKey;
|
||
|
this.effectiveTime = validFrom.ToUniversalTime();
|
||
|
this.expirationTime = validTo.ToUniversalTime();
|
||
|
this.isLifetimeSet = true;
|
||
|
this.isRequestedTokenClosed = isRequestedTokenClosed;
|
||
|
this.issuedTokenBuffer = issuedTokenBuffer;
|
||
|
this.isReceiver = true;
|
||
|
this.isReadOnly = true;
|
||
|
}
|
||
|
|
||
|
public string Context
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.context;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.context = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public string TokenType
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.tokenType;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.tokenType = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public SecurityKeyIdentifierClause RequestedAttachedReference
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.requestedAttachedReference;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.requestedAttachedReference = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public SecurityKeyIdentifierClause RequestedUnattachedReference
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.requestedUnattachedReference;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.requestedUnattachedReference = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DateTime ValidFrom
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.effectiveTime;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DateTime ValidTo
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.expirationTime;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public bool ComputeKey
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.computeKey;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.computeKey = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public int KeySize
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.keySize;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
if (value < 0)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("value", SR.GetString(SR.ValueMustBeNonNegative)));
|
||
|
this.keySize = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public bool IsRequestedTokenClosed
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.isRequestedTokenClosed;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.isRequestedTokenClosed = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public bool IsReadOnly
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.isReadOnly;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
protected Object ThisLock
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.thisLock;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
internal bool IsReceiver
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.isReceiver;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
internal SecurityStandardsManager StandardsManager
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.standardsManager;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.standardsManager = (value != null ? value : SecurityStandardsManager.DefaultInstance);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public SecurityToken EntropyToken
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
// PreSharp Bug: Property get methods should not throw exceptions.
|
||
|
#pragma warning suppress 56503
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemNotAvailableInDeserializedRSTR, "EntropyToken")));
|
||
|
}
|
||
|
return this.entropyToken;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public SecurityToken RequestedSecurityToken
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
// PreSharp Bug: Property get methods should not throw exceptions.
|
||
|
#pragma warning suppress 56503
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemNotAvailableInDeserializedRSTR, "IssuedToken")));
|
||
|
}
|
||
|
return this.issuedToken;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.isReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.issuedToken = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public SecurityToken RequestedProofToken
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
// PreSharp Bug: Property get methods should not throw exceptions.
|
||
|
#pragma warning suppress 56503
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemNotAvailableInDeserializedRSTR, "ProofToken")));
|
||
|
}
|
||
|
return this.proofToken;
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
if (this.isReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.proofToken = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public XmlElement RequestSecurityTokenResponseXml
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (!this.isReceiver)
|
||
|
{
|
||
|
// PreSharp Bug: Property get methods should not throw exceptions.
|
||
|
#pragma warning suppress 56503
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemAvailableInDeserializedRSTROnly, "RequestSecurityTokenXml")));
|
||
|
}
|
||
|
return this.rstrXml;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
internal object AppliesTo
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
// PreSharp Bug: Property get methods should not throw exceptions.
|
||
|
#pragma warning suppress 56503
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemNotAvailableInDeserializedRST, "AppliesTo")));
|
||
|
}
|
||
|
return this.appliesTo;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
internal XmlObjectSerializer AppliesToSerializer
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
// PreSharp Bug: Property get methods should not throw exceptions.
|
||
|
#pragma warning suppress 56503
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemNotAvailableInDeserializedRST, "AppliesToSerializer")));
|
||
|
}
|
||
|
return this.appliesToSerializer;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
internal Type AppliesToType
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
// PreSharp Bug: Property get methods should not throw exceptions.
|
||
|
#pragma warning suppress 56503
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemNotAvailableInDeserializedRST, "AppliesToType")));
|
||
|
}
|
||
|
return this.appliesToType;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
internal bool IsLifetimeSet
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
// PreSharp Bug: Property get methods should not throw exceptions.
|
||
|
#pragma warning suppress 56503
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemNotAvailableInDeserializedRSTR, "IsLifetimeSet")));
|
||
|
}
|
||
|
return this.isLifetimeSet;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
internal System.IdentityModel.XmlBuffer IssuedTokenBuffer
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return this.issuedTokenBuffer;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void SetIssuerEntropy(byte[] issuerEntropy)
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.entropyToken = (issuerEntropy != null) ? new NonceToken(issuerEntropy) : null;
|
||
|
}
|
||
|
|
||
|
internal void SetIssuerEntropy(WrappedKeySecurityToken issuerEntropy)
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.entropyToken = issuerEntropy;
|
||
|
}
|
||
|
|
||
|
public SecurityToken GetIssuerEntropy()
|
||
|
{
|
||
|
return this.GetIssuerEntropy(null);
|
||
|
}
|
||
|
|
||
|
internal SecurityToken GetIssuerEntropy(SecurityTokenResolver resolver)
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
return this.standardsManager.TrustDriver.GetEntropy(this, resolver);
|
||
|
}
|
||
|
else
|
||
|
return this.entropyToken;
|
||
|
}
|
||
|
|
||
|
public void SetLifetime(DateTime validFrom, DateTime validTo)
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
if (validFrom.ToUniversalTime() > validTo.ToUniversalTime())
|
||
|
{
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.GetString(SR.EffectiveGreaterThanExpiration));
|
||
|
}
|
||
|
this.effectiveTime = validFrom.ToUniversalTime();
|
||
|
this.expirationTime = validTo.ToUniversalTime();
|
||
|
this.isLifetimeSet = true;
|
||
|
}
|
||
|
|
||
|
public void SetAppliesTo<T>(T appliesTo, XmlObjectSerializer serializer)
|
||
|
{
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
if (appliesTo != null && serializer == null)
|
||
|
{
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serializer");
|
||
|
}
|
||
|
this.appliesTo = appliesTo;
|
||
|
this.appliesToSerializer = serializer;
|
||
|
this.appliesToType = typeof(T);
|
||
|
}
|
||
|
|
||
|
public void GetAppliesToQName(out string localName, out string namespaceUri)
|
||
|
{
|
||
|
if (!this.isReceiver)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemAvailableInDeserializedRSTOnly, "MatchesAppliesTo")));
|
||
|
this.standardsManager.TrustDriver.GetAppliesToQName(this, out localName, out namespaceUri);
|
||
|
}
|
||
|
|
||
|
public T GetAppliesTo<T>()
|
||
|
{
|
||
|
return this.GetAppliesTo<T>(DataContractSerializerDefaults.CreateSerializer(typeof(T), DataContractSerializerDefaults.MaxItemsInObjectGraph));
|
||
|
}
|
||
|
|
||
|
public T GetAppliesTo<T>(XmlObjectSerializer serializer)
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
if (serializer == null)
|
||
|
{
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serializer");
|
||
|
}
|
||
|
return this.standardsManager.TrustDriver.GetAppliesTo<T>(this, serializer);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return (T)this.appliesTo;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
internal void SetBinaryNegotiation(BinaryNegotiation negotiation)
|
||
|
{
|
||
|
if (negotiation == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("negotiation");
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.negotiationData = negotiation;
|
||
|
}
|
||
|
|
||
|
internal BinaryNegotiation GetBinaryNegotiation()
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
return this.standardsManager.TrustDriver.GetBinaryNegotiation(this);
|
||
|
else
|
||
|
return this.negotiationData;
|
||
|
}
|
||
|
|
||
|
internal void SetAuthenticator(byte[] authenticator)
|
||
|
{
|
||
|
if (authenticator == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("authenticator");
|
||
|
if (this.IsReadOnly)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
||
|
this.authenticator = DiagnosticUtility.Utility.AllocateByteArray(authenticator.Length);
|
||
|
Buffer.BlockCopy(authenticator, 0, this.authenticator, 0, authenticator.Length);
|
||
|
}
|
||
|
|
||
|
internal byte[] GetAuthenticator()
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
return this.standardsManager.TrustDriver.GetAuthenticator(this);
|
||
|
else
|
||
|
{
|
||
|
if (this.authenticator == null)
|
||
|
return null;
|
||
|
else
|
||
|
{
|
||
|
byte[] result = DiagnosticUtility.Utility.AllocateByteArray(this.authenticator.Length);
|
||
|
Buffer.BlockCopy(this.authenticator, 0, result, 0, this.authenticator.Length);
|
||
|
return result;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void OnWriteTo(XmlWriter w)
|
||
|
{
|
||
|
if (this.isReceiver)
|
||
|
{
|
||
|
this.rstrXml.WriteTo(w);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.standardsManager.TrustDriver.WriteRequestSecurityTokenResponse(this, w);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void WriteTo(XmlWriter writer)
|
||
|
{
|
||
|
if (writer == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
|
||
|
if (this.IsReadOnly)
|
||
|
{
|
||
|
// cache the serialized bytes to ensure repeatability
|
||
|
if (this.cachedWriteBuffer == null)
|
||
|
{
|
||
|
MemoryStream stream = new MemoryStream();
|
||
|
using (XmlDictionaryWriter binaryWriter = XmlDictionaryWriter.CreateBinaryWriter(stream, XD.Dictionary))
|
||
|
{
|
||
|
this.OnWriteTo(binaryWriter);
|
||
|
binaryWriter.Flush();
|
||
|
stream.Flush();
|
||
|
stream.Seek(0, SeekOrigin.Begin);
|
||
|
this.cachedWriteBuffer = stream.GetBuffer();
|
||
|
this.cachedWriteBufferLength = (int)stream.Length;
|
||
|
}
|
||
|
}
|
||
|
writer.WriteNode(XmlDictionaryReader.CreateBinaryReader(this.cachedWriteBuffer, 0, this.cachedWriteBufferLength, XD.Dictionary, XmlDictionaryReaderQuotas.Max), false);
|
||
|
}
|
||
|
else
|
||
|
this.OnWriteTo(writer);
|
||
|
}
|
||
|
|
||
|
public static RequestSecurityTokenResponse CreateFrom(XmlReader reader)
|
||
|
{
|
||
|
return CreateFrom(SecurityStandardsManager.DefaultInstance, reader);
|
||
|
}
|
||
|
|
||
|
public static RequestSecurityTokenResponse CreateFrom(XmlReader reader, MessageSecurityVersion messageSecurityVersion, SecurityTokenSerializer securityTokenSerializer)
|
||
|
{
|
||
|
return CreateFrom(SecurityUtils.CreateSecurityStandardsManager(messageSecurityVersion, securityTokenSerializer), reader);
|
||
|
}
|
||
|
|
||
|
internal static RequestSecurityTokenResponse CreateFrom(SecurityStandardsManager standardsManager, XmlReader reader)
|
||
|
{
|
||
|
return standardsManager.TrustDriver.CreateRequestSecurityTokenResponse(reader);
|
||
|
}
|
||
|
|
||
|
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
|
||
|
{
|
||
|
WriteTo(writer);
|
||
|
}
|
||
|
|
||
|
public void MakeReadOnly()
|
||
|
{
|
||
|
if (!this.isReadOnly)
|
||
|
{
|
||
|
this.isReadOnly = true;
|
||
|
this.OnMakeReadOnly();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public GenericXmlSecurityToken GetIssuedToken(SecurityTokenResolver resolver, IList<SecurityTokenAuthenticator> allowedAuthenticators, SecurityKeyEntropyMode keyEntropyMode, byte[] requestorEntropy, string expectedTokenType,
|
||
|
ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies)
|
||
|
{
|
||
|
return this.GetIssuedToken(resolver, allowedAuthenticators, keyEntropyMode, requestorEntropy, expectedTokenType, authorizationPolicies, 0, false);
|
||
|
}
|
||
|
|
||
|
public virtual GenericXmlSecurityToken GetIssuedToken(SecurityTokenResolver resolver, IList<SecurityTokenAuthenticator> allowedAuthenticators, SecurityKeyEntropyMode keyEntropyMode, byte[] requestorEntropy, string expectedTokenType,
|
||
|
ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies, int defaultKeySize, bool isBearerKeyType)
|
||
|
{
|
||
|
if (!this.isReceiver)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemAvailableInDeserializedRSTROnly, "GetIssuedToken")));
|
||
|
|
||
|
return this.standardsManager.TrustDriver.GetIssuedToken(this, resolver, allowedAuthenticators, keyEntropyMode, requestorEntropy, expectedTokenType, authorizationPolicies, defaultKeySize, isBearerKeyType);
|
||
|
}
|
||
|
|
||
|
public virtual GenericXmlSecurityToken GetIssuedToken(string expectedTokenType, ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies, RSA clientKey)
|
||
|
{
|
||
|
if (!this.isReceiver)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ItemAvailableInDeserializedRSTROnly, "GetIssuedToken")));
|
||
|
|
||
|
return this.standardsManager.TrustDriver.GetIssuedToken(this, expectedTokenType, authorizationPolicies, clientKey);
|
||
|
}
|
||
|
|
||
|
protected internal virtual void OnWriteCustomAttributes(XmlWriter writer)
|
||
|
{ }
|
||
|
|
||
|
protected internal virtual void OnWriteCustomElements(XmlWriter writer)
|
||
|
{ }
|
||
|
|
||
|
protected virtual void OnMakeReadOnly() { }
|
||
|
|
||
|
public static byte[] ComputeCombinedKey(byte[] requestorEntropy, byte[] issuerEntropy, int keySizeInBits)
|
||
|
{
|
||
|
if (requestorEntropy == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestorEntropy");
|
||
|
if (issuerEntropy == null)
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuerEntropy");
|
||
|
// Do a sanity check here. We don't want to allow invalid keys or keys that are too
|
||
|
// large.
|
||
|
if ((keySizeInBits < minSaneKeySizeInBits) || (keySizeInBits > maxSaneKeySizeInBits))
|
||
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(SR.GetString(SR.InvalidKeySizeSpecifiedInNegotiation, keySizeInBits, minSaneKeySizeInBits, maxSaneKeySizeInBits)));
|
||
|
Psha1DerivedKeyGenerator generator = new Psha1DerivedKeyGenerator(requestorEntropy);
|
||
|
return generator.GenerateDerivedKey(new byte[] { }, issuerEntropy, keySizeInBits, 0);
|
||
|
}
|
||
|
}
|
||
|
}
|