CA Business Service Insight provides two interfaces that need to be implemented in order to extend the authentication restrictions:
The following is a detailed description of the interfaces that need to be implemented by the developer, noting the data structure member order.
[WebService(Namespace = "http://Insight.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public interface IAuthenticationService
{
[WebMethod]
AuthenticationResult Authenticate(UserCredentials user);
[WebMethod]
AuthenticationResult EnforcePasswordPolicy (UserCredentials user);
}
public sealed class UserCredentials
{
public string Username;
public string Password;
public string Organization;
}
public sealed class AuthenticationResult
{
public bool IsAuthenticated;
public string ErrorMessage;
}
The following is an example for implementing the above web services:
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
/// <summary>
/// Summary description for PreAuthenticationExample
/// </summary>
[WebService(Namespace = "http://CA.com")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class PreAuthenticationExample : System.Web.Services.WebService
{
public class UserCredentials
{
public string Username;
public string Password;
public string Organization;
}
public sealed class AuthorizationResult
{
public bool IsAuthenticated;
public string ErrorMessage;
}
public PreAuthenticationExample()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public AuthorizationResult Authenticate(UserCredentials user, string state)
{
AuthorizationResult Result = new AuthorizationResult();
if (user.Password == "DeactivateMe")
{
Result.IsAuthenticated = false;
Result.ErrorMessage = "The user became inactive. Contract your system administrator";
UserManagementService Um = new UserManagementService();
Um.DeactivateUser(user.Username, user.Organization);
}
else
{
Result.IsAuthenticated = true;
}
return Result;
}
[WebMethod]
public AuthorizationResult EnforcePasswordPolicy(UserCredentials user, string state)
{
AuthorizationResult Result = new AuthorizationResult();
//Do not allow password that is identical to username or shorter than 7 characters
if (user.Username==user.Password || user.Password.Length<7)
{
Result.IsAuthenticated = false;
Result.ErrorMessage = "Invalid password.";
}
else
{
Result.IsAuthenticated = true;
}
return Result;
}
}
| Copyright © 2012 CA. Tous droits réservés. | Envoyer un courriel à CA Technologies sur cette rubrique |