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(); } }
public static FramingConnectionDuplexSession CreateSession(FramingDuplexSessionChannel channel, StreamUpgradeAcceptor upgradeAcceptor) { StreamSecurityUpgradeAcceptor security = upgradeAcceptor as StreamSecurityUpgradeAcceptor; if (security == null) { return(new FramingConnectionDuplexSession(channel)); } else { return(new SecureConnectionDuplexSession(channel)); } }
private void WriteAuditFailure(StreamSecurityUpgradeAcceptor securityUpgradeAcceptor, Exception exception) { try { this.WriteAuditEvent(securityUpgradeAcceptor, AuditLevel.Failure, exception); } catch (Exception exception2) { Exception exception1 = exception2; if (Fx.IsFatal(exception1)) { throw; } Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception1, TraceEventType.Error); } }
private void SetupSecurityIfNecessary(StreamUpgradeAcceptor upgradeAcceptor) { StreamSecurityUpgradeAcceptor streamSecurityUpgradeAcceptor = upgradeAcceptor as StreamSecurityUpgradeAcceptor; if (streamSecurityUpgradeAcceptor != null) { this.security = streamSecurityUpgradeAcceptor.GetRemoteSecurity(); if (this.security == null) { string remoteSecurityNotNegotiatedOnStreamUpgrade = Resources.RemoteSecurityNotNegotiatedOnStreamUpgrade; object[] via = new object[] { this.Via }; Exception protocolException = new ProtocolException(Microsoft.ServiceBus.SR.GetString(remoteSecurityNotNegotiatedOnStreamUpgrade, via)); throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(protocolException); } this.WriteAuditEvent(streamSecurityUpgradeAcceptor, AuditLevel.Success, null); } }
private static void SetupSecurityIfNecessary(FramingConnection connection) { StreamSecurityUpgradeAcceptor securityUpgradeAcceptor = connection.StreamUpgradeAcceptor as StreamSecurityUpgradeAcceptor; if (securityUpgradeAcceptor != null) { var remoteSecurity = securityUpgradeAcceptor.GetRemoteSecurity(); if (remoteSecurity == null) { Exception securityFailedException = new ProtocolException( SR.Format(SR.RemoteSecurityNotNegotiatedOnStreamUpgrade, connection.Via)); //WriteAuditFailure(securityUpgradeAcceptor, securityFailedException); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(securityFailedException); } else { connection.SecurityMessageProperty = remoteSecurity; // Audit Authentication Success //WriteAuditEvent(securityUpgradeAcceptor, AuditLevel.Success, null); } } }
private void WriteAuditEvent(StreamSecurityUpgradeAcceptor securityUpgradeAcceptor, AuditLevel auditLevel, Exception exception) { }