public void CanCreateExternal() { Hashtable props = new Hashtable(); string[] mechanisms = new string[] { "EXTERNAL", "OTHER" }; ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this); Assert.IsNotNull(client); Assert.IsInstanceOfType(typeof(ExternalSaslClient), client); }
public void ReturnsNullIfNoFactoryFound() { Hashtable props = new Hashtable(); props.Add(SaslProperties.PolicyNoPlainText, true); string[] mechanisms = new string[] { "PLAIN", "OTHER" }; ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this); Assert.IsNull(client); }
public void CanCreateDigest() { Hashtable props = new Hashtable(); string[] mechanisms = new string[] { "DIGEST-MD5", "OTHER" }; ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this); Assert.IsNotNull(client); Assert.IsInstanceOfType(typeof(DigestSaslClient), client); }
public void CanCreateAnonymous() { Hashtable props = new Hashtable(); string[] mechanisms = new string[] { "ANONYMOUS", "OTHER" }; ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this); Assert.IsNotNull(client); Assert.IsInstanceOfType(typeof(AnonymousSaslClient), client); }
public void CanCreatePlain() { Hashtable props = new Hashtable(); string[] mechanisms = new string[] { "PLAIN", "OTHER" }; ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this); Assert.IsNotNull(client); Assert.IsInstanceOfType(typeof(PlainSaslClient), client); }
public void ChoosesStrongerMechanism() { Hashtable props = new Hashtable(); string[] mechanisms = new string[] { "PLAIN", "OTHER", "CRAM-MD5" }; ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this); Assert.IsNotNull(client); Assert.IsInstanceOfType(typeof(CramMD5SaslClient), client); }
public void ParsesConfigurationSection() { // if the TEST mechanism is available, then we know // the configuration section worked! Hashtable props = new Hashtable(); string[] mechanisms = new string[] { "TEST" }; ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this); Assert.IsNotNull(client); Assert.IsInstanceOfType(typeof(TestSaslClient), client); }
public static UUID Parse(string hex) { if (hex.Length != ByteLength * 2) { throw new Exception("Cannot parse UUID/GUID of invalid length"); } UUID id = new UUID(); byte *result = (byte *)&id.a; int n = 0, i = 0; while (n < ByteLength) { result[n] = (byte)(Sasl.FromHexChar(hex[i++]) << 4); result[n++] += Sasl.FromHexChar(hex[i++]); } return(id); }
public void Bind(String dn, String password, DigestType digestType) { if (fCurrentConnection == null) { Open(); } if (String.IsNullOrEmpty(dn) || String.IsNullOrEmpty(password)) { digestType = DigestType.None; } switch (digestType) { case DigestType.MD5: { Int32 lSequenceId = SendLdapRequest(Asn1.LDAPBINDREQ, new BerInteger(LdapVersion), new BerString(Asn1.OCTETSTRING, ""), new BerSequence(Asn1.LDAPBINDSASL, new BerString(Asn1.OCTETSTRING, "DIGEST-MD5"))); Response lResponse = ReadResponse(); if (lResponse.SequenceId != lSequenceId) { throw new LdapException("Invalid sequence id in bind response"); } if (lResponse.Code != 14 || lResponse.RestData == null || lResponse.RestData[0].Type != BerType.String) // 14 = Sasl bind in progress { throw new LdapException(lResponse.Code); } String lResult = ((BerString)lResponse.RestData[0]).Value; String lEncodedResult = Sasl.MD5Login(lResult, dn, password, GetTargetHostName()); lSequenceId = SendLdapRequest(Asn1.LDAPBINDREQ, new BerInteger(LdapVersion), new BerString(Asn1.OCTETSTRING, ""), new BerSequence(Asn1.LDAPBINDSASL, new BerString(Asn1.OCTETSTRING, lEncodedResult))); lResponse = ReadResponse(); if (lResponse.SequenceId != lSequenceId) { throw new LdapException("Invalid sequence id in bind response"); } if (lResponse.Code != 14 || lResponse.RestData == null || lResponse.RestData[0].Type != BerType.String) // 14 = Sasl bind in progress { throw new LdapException(lResponse.Code); } lSequenceId = SendLdapRequest(Asn1.LDAPBINDREQ, new BerInteger(LdapVersion), new BerString(Asn1.OCTETSTRING, ""), new BerSequence(Asn1.LDAPBINDSASL, new BerString(Asn1.OCTETSTRING, "DIGEST-MD5"))); lResponse = ReadResponse(); if (lResponse.SequenceId != lSequenceId) { throw new LdapException("Invalid sequence id in bind response"); } if (lResponse.Code != 0) { throw new LdapException(lResponse.Code); } break; } default: { Int32 lSequenceId = SendLdapRequest(Asn1.LDAPBINDREQ, new BerInteger(LdapVersion), new BerString(Asn1.OCTETSTRING, dn), new BerString(Asn1.LDAPBINDPASSWORD, password)); Response lResponse = ReadResponse(); if (lResponse.SequenceId != lSequenceId) { throw new LdapException("Invalid sequence id in bind response"); } if (lResponse.Code != 0) { throw new LdapException(lResponse.Code); } break; } } fLoggedIn = true; }