//****************************************************************************************************** // ISecurityProvider.cs - Gbtc // // Copyright © 2012, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://www.opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 06/25/2010 - Pinal C. Patel // Generated original version of source code. // 12/03/2010 - Pinal C. Patel // Added TranslateRole() to allow providers to perform translation on role name. // 01/05/2011 - Pinal C. Patel // Added CanRefreshData, CanUpdateData, CanResetPassword and CanChangePassword properties along // with accompanying RefreshData(), UpdateData(), ResetPassword() and ChangePassword() methods. // 12/20/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** using System; using System.Collections.Generic; using System.Diagnostics; using System.Security; using System.Security.Principal; using GSF.Configuration; namespace GSF.Security { /// /// Defines the function signature delegate used for logging events from the . /// /// The source by which the application is registered on the specified computer. /// The string to write to the event log. /// One of the values. /// The application-specific identifier for the event. public delegate void LogEventFunctionSignature(string source, string message, EventLogEntryType type, int eventID); /// /// Defines a provider of role-based security in applications. /// public interface ISecurityProvider : IPersistSettings { #region [ Properties ] /// /// Gets or sets the name of the application being secured as defined in the backend security data store. /// string ApplicationName { get; set; } /// /// Gets or sets the connection string to be used for connection to the backend security data store. /// string ConnectionString { get; set; } /// /// Gets or sets the principal used for passthrough authentication. /// IPrincipal PassthroughPrincipal { get; set; } /// /// Gets or sets the password as a . /// SecureString SecurePassword { get; set; } /// /// Gets or sets as clear text password. /// string Password { get; set; } /// /// Gets the object containing information about the user. /// UserData UserData { get; } /// /// Gets the flag that indicates whether the user was /// authenticated during the last authentication attempt. /// bool IsUserAuthenticated { get; } /// /// Gets the flag that indicates whether the user /// needs to be redirected after the Authentication attempt. /// Could be used for asking Users to confirm Messages etc. /// bool IsRedirectRequested { get; } /// /// Gets the URI that user will be redirected to if is set. /// string RequestedRedirect { get; } /// /// Gets a boolean value that indicates whether operation is supported. /// bool CanRefreshData { get; } /// /// Gets a boolean value that indicates whether operation is supported. /// bool CanResetPassword { get; } /// /// Gets a boolean value that indicates whether operation is supported. /// bool CanChangePassword { get; } /// /// Gets an authentication failure reason, if set by the provider when authentication fails. /// string AuthenticationFailureReason { get; } /// /// Gets or sets the to use for logging security events for the implementation. /// /// /// Set to null to use default handler, i.e., . /// LogEventFunctionSignature LogEvent { get; set; } #endregion #region [ Methods ] /// /// Authenticates the user. /// /// true if the user is authenticated, otherwise false. bool Authenticate(); /// /// Refreshes the from the backend data store. /// /// true if is refreshed, otherwise false. bool RefreshData(); /// /// Resets user password in the backend data store. /// /// Answer to the user's security question. /// true if the password is reset, otherwise false. bool ResetPassword(string securityAnswer); /// /// Changes user password in the backend data store. /// /// User's current password. /// User's new password. /// true if the password is changed, otherwise false. bool ChangePassword(string oldPassword, string newPassword); /// /// Performs a translation of the specified user . /// /// The user role to be translated. /// The user role that the specified user translates to. string TranslateRole(string role); /// /// Performs a translation of the default login page to a different endpoint. /// /// The URI of the login page specified in the AppSettings /// The URI originally requested. /// The URI requested by the client /// The Referrer as specified in the request header /// The URI to be redirected to string TranslateRedirect(string loginUrl, Uri uri, string encodedPath, string referrer); /// /// Gets a list of Roles for this user for a specified ApplicationId. /// /// The applicationId for the roles to be returned. /// The roles that the specified user has. List GetUserRoles(string applicationId); #endregion } }