39
Author: Bill Buchanan Author: Bill Buchanan Author: Prof Bill Buchanan .NET Framework Name: Prof Bill Buchanan, C63 Email: [email protected] Leader: Centre for Dist. Comp. & Security Aims: WWF/WCF

WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

  • Upload
    ngongoc

  • View
    226

  • Download
    5

Embed Size (px)

Citation preview

Page 1: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

Name: Prof Bill Buchanan, C63

Email: [email protected]

Leader: Centre for Dist. Comp. & Security

Aims: WWF/WCF

Page 2: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

Windows Workflow Foundation

Page 3: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

What’s in it?

Common

workflow

technology

Process-

oriented view

of software

development

State machine

workflows

Sequential

workflows

Windows

Workflow

Foundations

Page 4: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow methodology

Traditional codingWorkflow creation

Trace for sequential and event-

driven code to make sure it is

working correctly

Define the flow of activities, either

for sequential flow or state-based

Activity 1

Activity 2

Activity n

Integrate activitiesCall methods

Create instances

Declare classes and methods

Write code

namespace WorkflowConsoleApplication4_state{

private void codeActivity5_ExecuteCode(object sender) { Console.WriteLine("Pass"); }

}}

Page 5: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Sequential workflow

Pick-up phone

Dial number

Wait for answer

Answer?

Hungry?

Yes

End

Start

No

Order pizza

Yes

Take order

Order acceptedNo

Yes

End

Get ingredients

Handover pizza

End

Page 6: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-machine workflow

User is hungry

Start

Handover pizza

End

Order pizza

Take orderRe-order pizzaAccept

call

No answer

Make pizza

Pizza

ready

Order

successfu

l

Accept

call

EndNo

answer

Delivery pizza

Address found

Get rid of

pizza

Address

not found

End

Pizza

wanted

Page 7: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow types

Sequential

Workflow LibrarySharePoint State

Machine

SharePoint

Sequential

Workflow

State Machine

Workflow Library

Sequential Console

Application

State Machine

Workflow Console

Application

Page 8: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow layered architecture

· Workflows.

· Rules.

· Built-in activities.

· Custom activities.

· Workflow execution (Rules, tracking and scheduling).

· Workflow lifecycle (State, activation).

· Communication.

· Persistence.

· Tracking.

· Timer.

· Transactions.

· Threading.

Workflow Model

Layer

Runtime Layer

Hosting Layer

Host process

Page 9: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow layered architecture

· Workflows.

· Rules.

· Built-in activities.

· Custom activities.

· Workflow execution (Rules, tracking and scheduling).

· Workflow lifecycle (State, activation).

Workflow Model

Layer

Runtime Layer

WorkflowRuntime workflowRuntime = new WorkflowRuntime();

workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;

workflowRuntime.StartRuntime();

WorkflowInstance workflowInstance =

workflowRuntime.CreateWorkflow(typeof(ActivityLibrary1.Activity1));

workflowInstance.Start();

Namespace Class

Event

Page 10: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

Sequential WF

Page 11: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

When sequential?

Workflow has well-defined

stimulus's, which use well

structured methods to catch

them

When the sequence of

activities is well-known, and

follow a defined sequence

When the workflow does not

have any unexpected

changes in operation

Page 12: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Sequential WF

Page 13: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Sequential WF

Page 14: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

What’s required?

public sealed partial class Workflow1: SequentialWorkflowActivity

{

int i;

public Workflow1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("Value less than 5");

Console.ReadLine();

}

private void codeActivity1_ExecuteCode_1(object sender, EventArgs e)

{

Console.WriteLine("Enter i>>");

i = Convert.ToInt32(Console.ReadLine());

}

private void codeActivity3_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("Value greater than 5");

Console.ReadLine();

}

private void delayActivity1_InitializeTimeoutDuration(object sender, EventArgs

e)

{

}

}

Page 15: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Workflow

public sealed partial class Workflow1: SequentialWorkflowActivity

{

ArrayList primes1 = new ArrayList(); bool flag1=false;

ArrayList primes2 = new ArrayList(); bool flag2 = false;

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 3; i < 100; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i=2;i<val/2;i++)

{

if ((val % i)==0) return false;

}

return true;

}

private void codeActivity2_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 100; i < 200; i++)

{

if (isprime(i)) primes2.Add(i);

}

this.flag2 = true;

}

private void codeActivity3_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("0-100, No of primes=" + Convert.ToString(primes1.Count));

Console.WriteLine(Convert.ToString(primes1[0]+"..."+Convert.ToString(primes1[primes1.Cou

nt-1])));

Console.WriteLine("100-200, No of primes=" + Convert.ToString(primes2.Count));

Console.WriteLine(Convert.ToString(primes2[0]+"..."+Convert.ToString(primes2[primes2.Cou

nt-1])));

Console.ReadLine();

flag1 = false;

}

Page 16: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Calling Workflow from another application

namespace ActivityLibrary1

{

public partial class Activity1: SequenceActivity

{

public ulong max=100;

public ArrayList primes1 = new ArrayList();

public bool flag1 = false;

public int primes

{

get { return primes1.Count; }

}

public object setmax

{

set { this.max = (ulong)value; }

get { return this.max; }

}

public Activity1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 3; i < this.max; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i = 2; i < val / 2; i++)

{

if ((val % i) == 0) return false;

}

return true;

}

}

}

Dictionary <string,object> parameters =

new Dictionary<string,object>();

parameters.Add("setmax", (ulong)400);

WorkflowInstance workflowInstance =

workflowRuntime.CreateWorkflow(

typeof(ActivityLibrary1.Activity1), parameters);

workflowInstance.Start();

void OnWorkflowCompleted(object sender,

WorkflowCompletedEventArgs e)

{

primes = (int)e.OutputParameters["primes"];

max = (ulong)e.OutputParameters["setmax"];

flag1 = true;

}

Page 17: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Calling Workflow from another application

namespace ActivityLibrary1

{

public partial class Activity1: SequenceActivity

{

public ulong max=100;

public ArrayList primes1 = new ArrayList();

public bool flag1 = false;

public int primes

{

get { return primes1.Count; }

}

public object setmax

{

set { this.max = (ulong)value; }

get { return this.max; }

}

public Activity1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 3; i < this.max; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i = 2; i < val / 2; i++)

{

if ((val % i) == 0) return false;

}

return true;

}

}

}

DLL

(Workflow)

Windows

Application

Page 18: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Calling Workflow from another application

namespace ActivityLibrary1

{

public partial class Activity1: SequenceActivity

{

public ulong max=100;

public ArrayList primes1 = new ArrayList();

public bool flag1 = false;

public int primes

{

get { return primes1.Count; }

}

public object setmax

{

set { this.max = (ulong)value; }

get { return this.max; }

}

public Activity1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

for (ulong i = 3; i < this.max; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i = 2; i < val / 2; i++)

{

if ((val % i) == 0) return false;

}

return true;

}

}

}

DLL

(Workflow)

Windows

Application

Add reference to DLL

Page 19: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

Calling Workflow from another application

namespace ActivityLibrary1

{

public partial class Activity1: SequenceActivity

{

public ulong max=100;

public ArrayList primes1 = new ArrayList();

public bool flag1 = false;

public int primes

{

get { return primes1.Count; }

}

public object setmax

{

set { this.max = (ulong)value; }

get { return this.max; }

}

public Activity1()

{

InitializeComponent();

}

private void codeActivity1_ExecuteCode(object sender,

EventArgs e)

{

for (ulong i = 3; i < this.max; i++)

{

if (isprime(i)) primes1.Add(i);

}

this.flag1 = true;

}

public bool isprime(ulong val)

{

for (ulong i = 2; i < val / 2; i++)

{

if ((val % i) == 0) return false;

}

return true;

}

}

}

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

int primes = 0;

bool flag1 = false;

ulong max = 0;

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

WorkflowRuntime workflowRuntime = new WorkflowRuntime();

workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;

workflowRuntime.StartRuntime();

Dictionary <string,object> parameters = new

Dictionary<string,object>();

parameters.Add("setmax", (ulong)400);

WorkflowInstance workflowInstance =

workflowRuntime.CreateWorkflow(typeof(ActivityLibrary1.Activity1),

parameters);

workflowInstance.Start();

while (flag1 == false)

{

Thread.Sleep(100);

}

this.textBox1.Text = "The number of primes is " +

Convert.ToString(primes)+" and "+Convert.ToString(this.max);

}

void OnWorkflowCompleted(object sender,

WorkflowCompletedEventArgs e)

{

primes = (int)e.OutputParameters["primes"];

max = (ulong)e.OutputParameters["setmax"];

flag1 = true;

}

}

Windows

Application

Start Workflow engine

Define parameters

Start workflow

End of workflow

Page 20: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

Event-driven WF

Page 21: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

When event-driven?

The workflow is driven by

external events and/or

influencing entities

Used when there is some

human interaction with a

process involving a delay in

processing or in different

flow of activities

Possible ad-hoc transactions

as opposed to sequential

flows

Page 22: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

SetState: Changes the state of the state

machine from one state to another. StateInitialization: Defines

activities that that are executed

when a new state is entered.

EventDriven: Used to define a

transition when a specific

event is received, when in a

given state.

State: Defines a particular state in the

state machine.

Page 23: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

Page 24: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

private void codeActivity1_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("Started...");

}

Page 25: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

private void codeActivity2_ExecuteCode(object sender, EventArgs e)

{

do

{

Console.WriteLine("What is the capital of Scotland?");

string input = Console.ReadLine();

if (input == "edinburgh") endexam = true;

else endexam = false;

} while (endexam==false);

}

Page 26: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WW

F.N

ET

Fra

me

wo

rk

State-based workflow

private void codeActivity3_ExecuteCode(object sender, EventArgs e)

{

Console.WriteLine("You have passed the exam");

Console.ReadLine();

}

Page 27: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

3.x

Windows Communications

Foundation

Page 28: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

What’s required?

Service-oriented

Architecture

(Services consumed

by consumers)

Consumer Consumer

Service

Service

Service

Application

Service

Service

Service

Service-oriented

Applications

Page 29: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

What’s required?

Web

services

.NET

RemotingDistributed

Transactions

Message

Queues

Windows

Communications

Foundations

Page 30: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

WCF

Distributed

Systems

Service-oriented

Applications (SoA)

Service-oriented

Architecture

A (Address)

B (Binding) – Protocol: SOAP over HTTP,

SOAP over TCP, SOAP over MQ

C (Contract) – Each service exposes a

Contract via an endpoint. URL defined for

endpoint.

Web Service

Web Client

End pointWSDL

Info sent

Message

Queue

Message

Queue

Page 31: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Service-oriented

Distributed

Systems

Service-oriented

Applications (SoA)

Service-oriented

Architecture

Boundaries are explicit.

Service compatibility is

determined based on policy.

Services are autonomous

Services share schema and

contract, not class

Page 32: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Service-oriented

Service

Service

Intermediate

Client

Client

Message

MessageMessage

Channels, Bindings, Contracts, Behaviours, Addresses and Endpoints.

Dealt with by WCF

Service

MessageMessage

Client

Service

A service becomes

a client

Page 33: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

5-layer WFC model

Application

Contracts

Runtime

Messaging

Hosting

This can be a range of hosts, such as

for Internet Information Services (IIS)

and starts and stops your services

automatically. Another is executable

files (.EXE) for the services are

started and stopped manually within

the code.

Supports difference channels and

encoders, and thus communication

for services.

This defines the behaviours within

services, which are loaded in this

layer.

In this layer services describe

themselves to clients. It defines data

and message contracts and bindings/

policies.

Applications are located at this layer.

Page 34: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

Service

Client

Capital(“scotland)

[ServiceContract]

public interface IService

{

[OperationContract]

public string GetCapital(string

Country);

}

ServiceHost svh = new

ServiceHost(typeof(ServiceImplementation));

svh.AddServiceEndpoint(

typeof(Tut1.Contract.IService),

new NetTcpBinding(),

"net.tcp://localhost:8080");

svh.Open();

System.Threading.Thread myCountryServer =

new

System.Threading.Thread(Tut1.Server.Program

.Main);

myCountryServer.IsBackground = true;

myCountryServer.Start();

ChannelFactory<Tut1.Contract.IService> scf;

scf = new

ChannelFactory<Tut1.Contract.IService>(

new NetTcpBinding(),

"net.tcp://localhost:8080");

Tut1.Contract.IService s;

s = scf.CreateChannel();

“edinburgh”

Net.tcp://localhost:8080

Page 35: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

System.Threading.Thread myCountryServer = new

System.Threading.Thread(Tut1.Server.Program.Main);

myCountryServer.IsBackground = true;

myCountryServer.Start();

System.Threading.Thread.Sleep(100);

ChannelFactory<Tut1.Contract.IService> scf;

scf = new ChannelFactory<Tut1.Contract.IService>(

new NetTcpBinding(),

"net.tcp://localhost:8080");

Tut1.Contract.IService s;

s = scf.CreateChannel();

while (true)

{

Console.Write("Enter a country: ");

string country = Console.ReadLine();

if (country == "") break;

string capital = s.Contact(country);

Console.WriteLine("The capital is " + capital);

}

[ServiceBehavior(InstanceContextMode =

InstanceContextMode.PerCall)]

class ServiceImplementation : Tut1.Contract.IService

{

public string Contact(string Country)

{

Console.WriteLine("Contacting server...");

if (Country == "scotland") return ("edinburgh");

else if (Country == "england") return ("london");

return "Not known";

}

}

public class Program

{

private static System.Threading.AutoResetEvent endServer =

new System.Threading.AutoResetEvent(false);

public static void Main()

{

ServiceHost svh = new

ServiceHost(typeof(ServiceImplementation));

svh.AddServiceEndpoint(

typeof(Tut1.Contract.IService),

new NetTcpBinding(), "net.tcp://localhost:8080");

svh.Open();

Console.WriteLine("Server running");

endServer.WaitOne();

Console.WriteLine("Server shutting down");

svh.Close();

Console.WriteLine("Server stopped");

}

}

using System.ServiceModel;

namespace Tut1.Contract

{

[ServiceContract]

public interface IService

{

[OperationContract]

string Contact(string message);

}

}DLL

Page 36: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

DLL

Page 37: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

System.Threading.Thread myCountryServer = new

System.Threading.Thread(Tut1.Server.Program.Main);

myCountryServer.IsBackground = true;

myCountryServer.Start();

System.Threading.Thread.Sleep(100);

ChannelFactory<Tut1.Contract.IService> scf;

scf = new ChannelFactory<Tut1.Contract.IService>(

new NetTcpBinding(),

"net.tcp://localhost:8080");

Tut1.Contract.IService s;

s = scf.CreateChannel();

while (true)

{

Console.Write("Enter a country: ");

string country = Console.ReadLine();

if (country == "") break;

string capital = s.Contact(country);

Console.WriteLine("The capital is " + capital);

}

[ServiceBehavior(InstanceContextMode =

InstanceContextMode.PerCall)]

class ServiceImplementation : Tut1.Contract.IService

{

public string Contact(string Country)

{

Console.WriteLine("Contacting server...");

if (Country == "scotland") return ("edinburgh");

else if (Country == "england") return ("london");

return "Not known";

}

}

public class Program

{

private static System.Threading.AutoResetEvent endServer =

new System.Threading.AutoResetEvent(false);

public static void Main()

{

ServiceHost svh = new

ServiceHost(typeof(ServiceImplementation));

svh.AddServiceEndpoint(

typeof(Tut1.Contract.IService),

new NetTcpBinding(), "net.tcp://localhost:8080");

svh.Open();

Console.WriteLine("Server running");

endServer.WaitOne();

Console.WriteLine("Server shutting down");

svh.Close();

Console.WriteLine("Server stopped");

}

}

using System.ServiceModel;

namespace Tut1.Contract

{

[ServiceContract]

public interface IService

{

[OperationContract]

string Contact(string message);

}

}DLL

Page 38: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Sta

tefu

l fire

wa

llN

etw

ork

Se

cu

rity

Stateful firewall

WC

F.N

ET

Fra

me

wo

rk

Practical Example

DLL

Page 39: WWF/WCFbillatnapier.com/wwf_wfc_ppt.pdf · n S t a t e f u l f i r e w a l l N e t w o r k S e c u r i t y S t a t e f u l f i r e w a l l W W F. N E T F r a m e w o r k: K DW¶V

Au

tho

r:

Bill

Buchanan

A

uth

or:

B

ill B

uchanan

Author: Prof Bill Buchanan

.NE

T F

ram

ew

ork

3.x

Windows Communications

Foundation