コード例 #1
0
        public static dSTSClientImpl CreatedSTSClient(
            string metadataUrl,
            string[] serverCommonName,
            string[] serverThumbprints,
            bool interactive              = false,
            string cloudServiceName       = null,
            string[] cloudServiceDNSNames = null)
        {
            dSTSClientImpl client = new dSTSClientImpl(
                metadataUrl,
                serverCommonName,
                serverThumbprints,
                interactive,
                cloudServiceName,
                cloudServiceDNSNames);

            if (client.Initialize())
            {
                return(client);
            }

            return(null);
        }
コード例 #2
0
ファイル: main.cs プロジェクト: zmyer/service-fabric
        static void Main(string[] args)
        {
            if (args.Length != 2)
            {
                ArgumentHelper();
                return;
            }

            string endpoint;
            string commonName = null;
            string thumbprint = null;

            if (!ParseArguments(args, out endpoint, out commonName, out thumbprint))
            {
                ArgumentHelper();
                return;
            }

            string[] commonNames = null;
            string[] thumbprints = null;
            if (!String.IsNullOrEmpty(commonName))
            {
                commonNames = new string[] { commonName };
            }
            else if (!String.IsNullOrEmpty(thumbprint))
            {
                thumbprints = new string[] { thumbprint };
            }
            else
            {
                ArgumentHelper();
                return;
            }

            dSTSClientImpl client = dSTSClientImpl.CreatedSTSClient(endpoint, commonNames, thumbprints, true);

            if (client == null)
            {
                Console.WriteLine("Client creation failed");
                return;
            }

            GenericXmlSecurityToken token;

            try
            {
                token = client.GetSecurityTokenInternal() as GenericXmlSecurityToken;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e.Message);
                return;
            }

            if (token == null)
            {
                Console.WriteLine("Token - invalid format");
                return;
            }

            DumpToken(token.TokenXml.OuterXml);
        }