コード例 #1
0
 /// <summary>
 /// <para>
 /// Check functions.
 /// </para>
 /// </summary>
 /// <param name="applicationId">
 /// application id.
 /// </param>
 /// <param name="sessionID">id of the current session</param>
 /// <param name="sessionToken">token for the current session</param>
 /// <param name="attributes">the attributes to be checked.</param>
 /// <returns>
 /// true if all attributes pass check, otherwise false.
 /// </returns>
 private static bool CheckFunctionalAttributes(string applicationId,
                                               string sessionID, string sessionToken, FunctionalAbilitiesAttribute[] attributes)
 {
     using (HermesAuthorizationServiceClient client =
                HermesAuthorizationServiceClient.GetClient())
     {
         IAuthorizationMappingProvider provider = CreateMapper();
         foreach (FunctionalAbilitiesAttribute attribute in attributes)
         {
             foreach (string functionalAbility in attribute.FunctionalAbilities)
             {
                 if (client.CheckFunction(sessionID, sessionToken,
                                          provider.GetFunctionName(functionalAbility)))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
コード例 #2
0
 /// <summary>
 /// <para>
 /// Get the function name using the <paramref name="referenceFunctionName"/>.
 /// </para>
 /// </summary>
 /// <param name="applicationId">
 /// application id.
 /// </param>
 /// <param name="sessionId">id of the current session</param>
 /// <param name="sessionToken">token for the current session</param>
 /// <param name="referenceFunctionName">
 /// Reference function name.
 /// </param>
 /// <returns></returns>
 public static IList <KeyValuePair <string, string> > GetFunctionAttributes
     (string applicationId, string sessionId,
     string sessionToken, string referenceFunctionName)
 {
     using (HermesAuthorizationServiceClient client =
                HermesAuthorizationServiceClient.GetClient())
     {
         IAuthorizationMappingProvider         provider   = CreateMapper();
         List <KeyValuePair <string, string> > attributes =
             client.GetFunctionAttributes(sessionId, sessionToken,
                                          provider.GetFunctionName(referenceFunctionName));
         List <KeyValuePair <string, string> > ret =
             new List <KeyValuePair <string, string> >();
         foreach (KeyValuePair <string, string> value in attributes)
         {
             ret.Add(new KeyValuePair <string, string>(
                         provider.GetFunctionAttributeName(
                             referenceFunctionName, value.Key), value.Value));
         }
         return(ret);
     }
 }