/// <summary> /// <para> /// Retrieve all of the rights a user has for a given entity. /// </para> /// </summary> /// /// <param name="sessionId">id of the current session</param> /// <param name="sessionToken">token for the current session</param> /// <param name="entityName">the name of the entity to check</param> /// <return> /// all of the rights the user has for the given entity /// </return> /// /// <exception cref="FaultException{TCFaultException}"> /// The inner exception contains: /// <see cref="ArgumentNullException"/> (if any argument is null), /// <see cref="ArgumentException"/> (if <paramref name="sessionId"/> or /// <paramref name="entityName"/> is empty), /// <see cref="InvalidSessionException"/>(if the specified session is /// not valid), <see cref="AuthorizationServiceException"/>(if there's /// a problem interacting with the wrapped authentication service), /// <see cref="ObjectDisposedException"/>(if the object has been /// disposed). /// </exception> public Rights GetEntityRights(string sessionId, string sessionToken, string entityName) { try { Helper.CheckString(entityName, "entityName"); CheckDisposed(); AuthLogin(sessionId, sessionToken); if (!_Entities.ContainsKey(entityName)) { throw new AuthorizationServiceException( String.Format("The entity name {0} is not configured.", entityName)); } return(_Entities[entityName]); } catch (Exception e) { Exception sde = PopulateSDE( "Error occurs while getting rights for entigy.", e, "Hermes.Services.Security.Authorization.TopCoder.HermesAuthorizationService.GetEntityRights", new string[] { "sessionId", "sessionToken", "entityName" }, new object[] { sessionId, sessionToken, entityName }, new string[0], new object[0], new string[] { "_Logins", "_Roles", "_Functions", "_FunctionsAttributes", "_Entities", "_AppId" }, new object[] { _Logins, _Roles, _Functions, _FunctionsAttributes, _Entities, _AppId }); throw new FaultException <TCFaultException>(TCFaultException.CreateFromException(sde), sde.Message); } }
/// <summary> /// <para> /// Check if the user for the specified session can execute the /// specified function. /// </para> /// </summary> /// /// <param name="sessionId">id of the current session</param> /// <param name="sessionToken">token for the current session</param> /// <param name="functionName">the name of the function to check</param> /// <return> /// true if the current user has rights to perform the specified /// function /// </return> /// /// <exception cref="FaultException{TCFaultException}"> /// The inner exception contains: /// <see cref="ArgumentNullException"/> (if any argument is null), /// <see cref="ArgumentException"/> (if <paramref name="sessionId"/> or /// <paramref name="functionName"/> is empty), /// <see cref="InvalidSessionException"/>(if the specified session is /// not valid), <see cref="AuthorizationServiceException"/>(if there's /// a problem interacting with the wrapped authentication service), /// <see cref="ObjectDisposedException"/>(if the object has been /// disposed). /// </exception> public bool CheckFunction(string sessionId, string sessionToken, string functionName) { try { Helper.CheckString(functionName, "functionName"); CheckDisposed(); AuthLogin(sessionId, sessionToken); if (_Functions.ContainsKey(functionName)) { return(_Functions[functionName]); } else { throw new AuthorizationServiceException( String.Format("The function name {0} is not configured.", functionName)); } } catch (Exception e) { Exception sde = PopulateSDE( "Error occurs while checking function.", e, "Hermes.Services.Security.Authorization.TopCoder.HermesAuthorizationService.CheckFunction", new string[] { "sessionId", "sessionToken", "functionName" }, new object[] { sessionId, sessionToken, functionName }, new string[0], new object[0], new string[] { "_Logins", "_Roles", "_Functions", "_FunctionsAttributes", "_Entities", "_AppId" }, new object[] { _Logins, _Roles, _Functions, _FunctionsAttributes, _Entities, _AppId }); throw new FaultException <TCFaultException>(TCFaultException.CreateFromException(sde), sde.Message); } }
/// <summary> /// <para> /// Set the applicaton id. /// </para> /// </summary> /// <param name="appId"> /// The applicaton id to be set. /// </param> /// <exception cref="FaultException{TCFaultException}"> /// The inner exception contains: /// <see cref="ArgumentNullException"/> (if any argument is null), /// <see cref="ArgumentException"/> (if <paramref name="appId"/> /// is empty), /// <see cref="ObjectDisposedException"/>(if the object has been /// disposed). /// </exception> public void SetApplication(string appId) { try { Helper.CheckString(appId, "appId"); CheckDisposed(); _AppId = appId; } catch (Exception e) { Exception sde = PopulateSDE( "Error occurs while checking function.", e, "Hermes.Services.Security.Authorization.TopCoder.HermesAuthorizationService.SetApplication", new string[] { "appId" }, new object[] { appId }, new string[0], new object[0], new string[] { "_Logins", "_Roles", "_Functions", "_FunctionsAttributes", "_Entities", "_AppId" }, new object[] { _Logins, _Roles, _Functions, _FunctionsAttributes, _Entities, _AppId }); throw new FaultException <TCFaultException>(TCFaultException.CreateFromException(sde), sde.Message); } }