I have a security method I would like to be able to sprinkle into other classes throughout my program. It is currently an abstract class but I feel it would be more appropriate as an interface. Can someone help me convert it? I wasn't able to call PrincipalIdentity() the same way I could with it being abstract.
public abstract class SecurityBase {
public GenericPrincipal PrincipalIdentity() {
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
string authenticationType = windowsIdentity.AuthenticationType;
string userName = windowsIdentity.Name.Split('\\')[1];;
GenericIdentity authenticatedGenericIdentity = new GenericIdentity(userName, authenticationType);
string[] Roles = //generate array;
GenericPrincipal pr = new GenericPrincipal(authenticatedGenericIdentity, Roles);
return pr;
}
}