To control who get to connect/invoke calls to the ESB Server you need to implement IAuthenticationProvider and IAuthorizationProvider.

IAuthenticationProvider is responsible for determining whether the caller requesting a connection to the ESB Server can make any further invocation such as Subscribing and Publishing to topics

IAuthorizationProvider is responsible for determining whether caller is allowed to create/edit subscriber or register topic/publish a message to topics.

//The following code would send credential to the ESB Server and use it to authorize subsequent calls such as subscribe, register, publish, and e.t.c

ESB.Authenticate("username", "password");

The following is an example of implementing IAuthenticationProvider and IAuthorizationProvider. You will need to reference PServiceBus.Core.dll in order to be able to implement the interfaces.

public class DefaultAuthenticationProvider : IAuthenticationProvider {
	#region IAuthenticationProvider Members
	public bool Authenticate(string username, string password) {
		var success = false;
		//Do some logic to verify user, e.x connect using database or facebook account
		return success;
	}
	#endregion
}
public class DefaultAuthorizationProvider : IAuthorizationProvider {
	#region IAuthorizationProvider Members
	public bool CanEditSubscriber(string username, string subscriberName) {
		//Do something to verify that user can edit specified subscriber information
		return true;
	}
	.......
}

 

 

In order to use the implementation, you will need to stop the PServiceBus.ServiceMonitor and all the PServiceBus.Gateway service. Navigate to the installation folder for the ESB Server and open the ESB WCF folder. Drop the dll and it dependencies need for your Security implementation and edit the app.config. Once done start the PServiceBus.ServiceMonitor and all the PServiceBus.Gateway services

Change the following line from this:

<securityConfig authorizationType="PServiceBus.Core.Security.DefaultAuthorizationProvider" authenticationType="PServiceBus.Core.Security.DefaultAuthenticationProvider"/>

to this:

<securityConfig authorizationType="Namespace.AuthorizationProviderClassName" authenticationType="Namespace.AuthenticationProviderClassName"/>

Last edited Dec 2, 2011 at 4:56 AM by rpgmaker, version 7

Comments

No comments yet.