コード例 #1
0
 public void ThirdPartyAuthorization()
 {
     certSOAPHeaderAuthStrategy = new CertificateSOAPHeaderAuthStrategy();
     subAuthorization = new SubjectAuthorization("testsubject");
     certSOAPHeaderAuthStrategy.ThirdPartyAuthorization = subAuthorization;
     Assert.IsNotNull(certSOAPHeaderAuthStrategy.ThirdPartyAuthorization);
 }
コード例 #2
0
 public void ThirdPartyAuthorization()
 {
     signSOAPHeaderAuthStrategy = new SignatureSOAPHeaderAuthStrategy();
     subAuthorization = new SubjectAuthorization("testsubject");
     signSOAPHeaderAuthStrategy.ThirdPartyAuthorization = subAuthorization;
     Assert.IsNotNull(signSOAPHeaderAuthStrategy.ThirdPartyAuthorization);
     Assert.AreEqual("testsubject", ((SubjectAuthorization)(signSOAPHeaderAuthStrategy.ThirdPartyAuthorization)).Subject);
 }
コード例 #3
0
 public void GenerateHeaderStrategyThirdPartyAuthorization()
 {
     certCredential = new CertificateCredential("testusername", "testpassword", "sdk-cert.p12", "KJAERUGBLVF6Y");
     certSOAPHeaderAuthStrategy = new CertificateSOAPHeaderAuthStrategy();
     subAuthorization = new SubjectAuthorization("testsubject");
     certSOAPHeaderAuthStrategy.ThirdPartyAuthorization = subAuthorization;
     certCredential.ThirdPartyAuthorization = subAuthorization;
     string payload = certSOAPHeaderAuthStrategy.GenerateHeaderStrategy(certCredential);
     XmlDocument xmlDoc = GetXmlDocument(payload);
     XmlNodeList xmlNodeListUsername = xmlDoc.GetElementsByTagName("Username");
     Assert.IsTrue(xmlNodeListUsername.Count > 0);
     Assert.AreEqual("testusername", xmlNodeListUsername[0].InnerXml);
     XmlNodeList xmlNodeListPassword = xmlDoc.GetElementsByTagName("Password");
     Assert.IsTrue(xmlNodeListPassword.Count > 0);
     Assert.AreEqual("testpassword", xmlNodeListPassword[0].InnerXml);
     XmlNodeList xmlNodeListSubject = xmlDoc.GetElementsByTagName("Subject");
     Assert.IsTrue(xmlNodeListSubject.Count > 0);
     Assert.AreEqual("testsubject", xmlNodeListSubject[0].InnerXml);
 }
コード例 #4
0
 public void GenerateHeaderStrategyThirdParty()
 {
     signCredential = new SignatureCredential("testusername", "testpassword", "testsignature");
     signSOAPHeaderAuthStrategy = new SignatureSOAPHeaderAuthStrategy();
     subAuthorization = new SubjectAuthorization("testsubject");
     signSOAPHeaderAuthStrategy.ThirdPartyAuthorization = subAuthorization;
     signCredential.ThirdPartyAuthorization = subAuthorization;
     string payload = signSOAPHeaderAuthStrategy.GenerateHeaderStrategy(signCredential);
     XmlDocument xmlDoc = GetXmlDocument(payload);
     XmlNodeList NodeListUsername = xmlDoc.GetElementsByTagName("Username");
     Assert.IsTrue(NodeListUsername.Count > 0);
     Assert.AreEqual("testusername", NodeListUsername[0].InnerXml);
     XmlNodeList xmlNodeListPassword = xmlDoc.GetElementsByTagName("Password");
     Assert.IsTrue(xmlNodeListPassword.Count > 0);
     Assert.AreEqual("testpassword", xmlNodeListPassword[0].InnerXml);
     XmlNodeList xmlNodeListSignature = xmlDoc.GetElementsByTagName("Signature");
     Assert.IsTrue(xmlNodeListSignature.Count > 0);
     Assert.AreEqual("testsignature", xmlNodeListSignature[0].InnerXml);
     XmlNodeList xmlNodeListSubject = xmlDoc.GetElementsByTagName("Subject");
     Assert.IsTrue(xmlNodeListSubject.Count > 0);
     Assert.AreEqual("testsubject", xmlNodeListSubject[0].InnerXml);
 }
コード例 #5
0
 public void ThirdPartyAuthorizationForSubject()
 {
     IThirdPartyAuthorization thirdPartyAuthorization = new SubjectAuthorization("Subject");
     signCredential.ThirdPartyAuthorization = thirdPartyAuthorization;
     Assert.AreEqual(((SubjectAuthorization)thirdPartyAuthorization).Subject, "Subject");
 }
コード例 #6
0
 public void ArgumentExceptionTest()
 {
     SubjectAuthorization subAuthorization = new SubjectAuthorization(null);
 }
コード例 #7
0
        /// <summary>
        /// Returns the API Credentials
        /// </summary>
        /// <param name="apiUserName"></param>
        /// <returns></returns>
        public ICredential GetCredentials(Dictionary<string, string> config, string apiUserName)
        {
            ICredential credential = null;
            Account accnt = GetAccount(config, apiUserName);
            if (accnt == null)
            {
                throw new MissingCredentialException("Missing credentials for " + apiUserName);
            }
            if (!string.IsNullOrEmpty(accnt.APICertificate))
            {
                CertificateCredential certCredential = new CertificateCredential(accnt.APIUserName, accnt.APIPassword, accnt.APICertificate, accnt.PrivateKeyPassword);
                certCredential.ApplicationId = accnt.ApplicationId;
                if (!string.IsNullOrEmpty(accnt.CertificateSubject))
                {
                    SubjectAuthorization subAuthorization = new SubjectAuthorization(accnt.CertificateSubject);
                    certCredential.ThirdPartyAuthorization = subAuthorization;
                }
                credential = certCredential;
            }
            else
            {
                SignatureCredential signCredential = new SignatureCredential(accnt.APIUserName, accnt.APIPassword, accnt.APISignature);
                signCredential.ApplicationId = accnt.ApplicationId;
                if (!string.IsNullOrEmpty(accnt.SignatureSubject))
                {
                    SubjectAuthorization subjectAuthorization = new SubjectAuthorization(accnt.SignatureSubject);
                    signCredential.ThirdPartyAuthorization = subjectAuthorization;
                }
                credential = signCredential;
            }
            ValidateCredentials(credential);

            return credential;
        }
コード例 #8
0
        /// <summary>
        /// Returns the API Credentials
        /// </summary>
        /// <param name="apiUserName"></param>
        /// <returns></returns>
        public ICredential GetCredentials(string apiUserName)
        {
            if (apiUserName == null)
            {
                apiUserName = GetDefaultAccountName();
            }

            ICredential credential = null;
            ConfigManager configMngr = ConfigManager.Instance;
            Account accnt = configMngr.GetAccount(apiUserName);
            if (accnt == null)
            {
                throw new MissingCredentialException("Missing credentials for " + apiUserName);
            }
            if (!string.IsNullOrEmpty(accnt.APICertificate))
            {
                CertificateCredential certCredential = new CertificateCredential(accnt.APIUsername, accnt.APIPassword, accnt.APICertificate, accnt.PrivateKeyPassword);
                certCredential.ApplicationID = accnt.ApplicationId;
                if (!string.IsNullOrEmpty(accnt.CertificateSubject))
                {
                    SubjectAuthorization subAuthorization = new SubjectAuthorization(accnt.CertificateSubject);
                    certCredential.ThirdPartyAuthorization = subAuthorization;
                }
                credential = certCredential;
            }
            else
            {
                SignatureCredential signCredential = new SignatureCredential(accnt.APIUsername, accnt.APIPassword, accnt.APISignature);
                signCredential.ApplicationID = accnt.ApplicationId;
                if (!string.IsNullOrEmpty(accnt.SignatureSubject))
                {
                    SubjectAuthorization subjectAuthorization = new SubjectAuthorization(accnt.SignatureSubject);
                    signCredential.ThirdPartyAuthorization = subjectAuthorization;
                }
                credential = signCredential;
            }
            ValidateCredentials(credential);

            return credential;
        }