29
Desenvolvimento com Windows Communication Foundation (WCF) Henrry Pires http://netponto.org 21ª Reunião Lisboa 18/06/2011

Desenvolvimento com Windows Communication Foundation (WCF)

Embed Size (px)

DESCRIPTION

Nesta apresentação, o Henrry aborda diversos tópicos relacionados com a criação e utilização de serviços em WCF no dia-a-dia, entre eles destacam-se técnicas para tratamento de erros de forma mais elegante, validação de user e password ao receber chamadas em um serviço e outras formas de autenticação, tracing, e outros temas, com muitas demonstrações práticas.

Citation preview

Page 1: Desenvolvimento com Windows Communication Foundation (WCF)

Desenvolvimento com Windows Communication Foundation (WCF)

Henrry Pires

http://netponto.org21ª Reunião Lisboa – 18/06/2011

Page 3: Desenvolvimento com Windows Communication Foundation (WCF)

Henrry Pires

11 anos de experiência profissional em TI

Há 9 anos a programar na plataforma .NET

Page 4: Desenvolvimento com Windows Communication Foundation (WCF)

Agenda

• Tracing

• Segurança

• Tratamento de Erros

Page 5: Desenvolvimento com Windows Communication Foundation (WCF)

Também disponível em vídeo...

Assista!http://vimeo.com/25902708

Page 6: Desenvolvimento com Windows Communication Foundation (WCF)

Tracing

Page 7: Desenvolvimento com Windows Communication Foundation (WCF)

TracingBasicamente queremos fazer tracing serve-nos para obter informações do estado daaplicação. Quando a app arranca, quandodeterminados processos são executados,erros entre outros. Seja qual for a informaçãodisponibilizada, o interesse é sempre omesmo: a app tem informação importantepara disponibilizar

Page 8: Desenvolvimento com Windows Communication Foundation (WCF)

Tracing

Tracing LevelsTrace level Description

Off Does not allow any events through.

Critical Allows only Critical events through.

Error Allows Critical and Error events through.

Warning Allows Critical, Error, and Warning events through.

Information Allows Critical, Error, Warning, and Information events through.

Verbose Allows Critical, Error, Warning, Information, and Verbose events through.

ActivityTracing Allows the Stop, Start, Suspend, Transfer, and Resume events through.

All Allows all events through.

Page 9: Desenvolvimento com Windows Communication Foundation (WCF)

Tracing

Tracing Assembly Assembly Name Description

System.ServiceModel

The most active (from a tracing perspective) of the assemblies. All the stages in the WCF message process are logged, including reading configuration information, performing transport-level actions, and processing

security requests.

System.ServiceModel .MessageLogging

Generates tracing information for all the messages that flow through the system.

System.ServiceModel .IdentityModel

Generates trace data related to the authentication and authorization mechanism used within WCF.

System.Runtime

.Serialization

Provides tracing information when objects are serialized or deserialized. Because this activity occurs quite often in WCF, this set of tracing

information is useful for seeing some of the raw content associated with

messages.

System.IO.Log Generates trace messages associated with accessing the interface to the Common Log File System (CLFS).

CardSpace Generates trace messages related to any CardSpace identity processing

that occurs within the context of a WCF application. System.ServiceModel

.Activation Creates traces related to the activation of the service portion of a WCF

communication channel.

Page 10: Desenvolvimento com Windows Communication Foundation (WCF)

Tracing

Page 11: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

Page 12: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

• Infra-estrutura

• A nível de utilizador

Page 13: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

• Infra-estrutura

– Transporte

– Mensagem

– Transporte com Credencias de Mensagem

Page 14: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

• A nível de utilizador–Windows Authentication

–Utilizador e password

–Certificados digitais

Page 15: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

• Transporte

– HTTPS

– TCP/IP

– MSMQ

Page 16: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

• Mensagem

– Certificados

– IssuedToken

– Utilizador

– Windows

Page 17: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

• DiferençasMensaguem Transporte

Leva consigo as credenciais Usa o sistema handshaking ou recursos externos para validar a Mensagem

A Mensagem está sempre encriptada Só está encriptada entre os end points

Encriptação parcial, total ou mesmo vários tipos de encriptação dentro da mesmaMensagem

A Mensagem é encriptada na sua totalidade com um único sistema

Page 18: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

A nível de utilizador

Nem todos os tipos de autenticação sãoválidos para todos os Bindings, exemplodisso é o basicHTTPBinding que só suportacertificados e Utilizador e Password

Page 19: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

• Certificado

Este método permite através de umcertificado digital autenticar tanto ocliente como o servidor. Todos osoutros métodos usam certificadospara fazer a comunicação

Page 20: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

Passos necessários para usar o certificado

Page 21: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

1. Identificar a store (storeName)AddressBook AuthRoot CertificateAuthority Disallowed

My Root TrustedPeople TrustedPublisher

Page 22: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

2. Localização da store (storeLocation)

CurrentUser

LocalMachine

Page 23: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

3. Tipo de pesquisa (x509FindType)

FindByThumbprint FindBySubjectName FindBySubjectDistinguishedName

FindByIssuerName

FindBySerialNumber FindByTimeNotYetValid FindByIssuerDistinguishedName

FindByTimeValid

FindByTemplateName FindByCertificatePolicy FindByApplicationPolicy FindByTimeExpired

FindByExtension FindByKeyUsage FindBySubjectKeyIdentifier

Page 24: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

3. Valor a pesquisar (findValue)

<certificateReferencefindValue="545c9b8e97d91fc75c74eb52c6908320088b4f39"x509FindType="FindByThumbprint"storeLocation="LocalMachine"storeName="My" />

Page 25: Desenvolvimento com Windows Communication Foundation (WCF)

Segurança

Page 26: Desenvolvimento com Windows Communication Foundation (WCF)

Questões?

Page 28: Desenvolvimento com Windows Communication Foundation (WCF)

Próximas reuniões presenciais

• 18/06/2011 – Junho

• 09/07/2011 – Julho (Coimbra)

• 23/07/2011 – Julho

• 27/08/2011 – Agosto

Reserva estes dias na agenda! :)

Page 29: Desenvolvimento com Windows Communication Foundation (WCF)

Obrigado!

Henrry [email protected]

http://henrrypires.wordpress.com

http://twitter.com/henrrypires