Beispiel #1
0
        /// <summary>
        /// Creates a new <see cref="ShibbolethToken"/> from the current values of the HTTP server variables.
        /// </summary>
        /// <returns></returns>
        public static ShibbolethToken CreateCurrent()
        {
            // Get all server variables.
            NameValueCollection vars = HttpContext.Current.Request.ServerVariables;

            // Create a new token and set its properties using the attached ServerVariable attributes.
            ShibbolethToken token = new ShibbolethToken();

            PropertyInfo[] properties = token.GetType().GetProperties();
            foreach (PropertyInfo property in properties)
            {
                ServerVariableAttribute attr = property.GetCustomAttribute <ServerVariableAttribute>();
                if (attr != null)
                {
                    string value = vars[attr.Name];
                    if (!String.IsNullOrEmpty(value))
                    {
                        property.SetValue(token, value);
                    }
                }
            }

            return(token);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new <see cref="ShibbolethToken"/> from the current values of the HTTP server variables.
        /// </summary>
        /// <returns></returns>
        public static ShibbolethToken CreateCurrent()
        {
            // Get all server variables.
            NameValueCollection vars = HttpContext.Current.Request.ServerVariables;

            // Create a new token and set its properties using the attached ServerVariable attributes.
            ShibbolethToken token = new ShibbolethToken();
            PropertyInfo[] properties = token.GetType().GetProperties();
            foreach( PropertyInfo property in properties )
            {
                ServerVariableAttribute attr = property.GetCustomAttribute<ServerVariableAttribute>();
                if( attr != null )
                {
                    string value = vars[ attr.Name ];
                    if( !String.IsNullOrEmpty( value ) )
                    {
                        property.SetValue( token, value );
                    }
                }
            }

            return token;
        }