예제 #1
0
        private static string GetSTSToken(Uri requestUri, string endPoint, string appliesTo)
        {
            var typeProvider = WIFTypeProvider.GetWIFTypes();

            if (typeProvider == null)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.UnableToLocateWIF, requestUri));
            }

            var     binding = new WS2007HttpBinding(SecurityMode.Transport);
            dynamic factory = Activator.CreateInstance(typeProvider.ChannelFactory, binding, endPoint);

            factory.TrustVersion = TrustVersion.WSTrust13;

            // Check if we can create 4.5 types.
            dynamic rst = Activator.CreateInstance(typeProvider.RequestSecurityToken);

            rst.RequestType = GetFieldValue <string>(typeProvider.RequestTypes, "Issue");
            rst.KeyType     = GetFieldValue <string>(typeProvider.KeyTypes, "Bearer");

            // Dynamic verifies the type of the instance so we cannot use it to assign a value for this property.
            var endPointAddress = Activator.CreateInstance(typeProvider.EndPoint, appliesTo);

            SetProperty(rst, "AppliesTo", endPointAddress);

            dynamic channel       = factory.CreateChannel();
            dynamic securityToken = channel.Issue(rst);

            return(securityToken.TokenXml.OuterXml);
        }
예제 #2
0
        private static string GetSTSToken(Uri requestUri, string endPoint, string appliesTo)
        {
            WIFTypeProvider wIFTypes = WIFTypeProvider.GetWIFTypes();

            if (wIFTypes == null)
            {
                object[] objArray1 = new object[] { requestUri };
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, NuGetResources.UnableToLocateWIF, objArray1));
            }
            WS2007HttpBinding binding = new WS2007HttpBinding(SecurityMode.Transport);

            object[] args = new object[] { binding, endPoint };
            object   obj2 = Activator.CreateInstance(wIFTypes.ChannelFactory, args);

            if (< > o__5.< > p__0 == null)
            {
                CSharpArgumentInfo[] argumentInfo = new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null) };