Ejemplo n.º 1
0
        public static ASPasswordCredentialIdentity ToCredentialIdentity(Cipher cipher)
        {
            if (!cipher?.Login?.Uris?.Any() ?? true)
            {
                return(null);
            }
            var uri = cipher.Login.Uris.FirstOrDefault()?.Uri?.Decrypt(cipher.OrganizationId);

            if (string.IsNullOrWhiteSpace(uri))
            {
                return(null);
            }
            var username = cipher.Login.Username?.Decrypt(cipher.OrganizationId);

            if (string.IsNullOrWhiteSpace(username))
            {
                return(null);
            }
            var serviceId = new ASCredentialServiceIdentifier(uri, ASCredentialServiceIdentifierType.Url);

            return(new ASPasswordCredentialIdentity(serviceId, username, cipher.Id));
        }
Ejemplo n.º 2
0
        public static ASPasswordCredentialIdentity ToCredentialIdentity(CipherView cipher)
        {
            if (!cipher?.Login?.Uris?.Any() ?? true)
            {
                return(null);
            }
            var uri = cipher.Login.Uris.FirstOrDefault(u => u.Match != Bit.Core.Enums.UriMatchType.Never)?.Uri;

            if (string.IsNullOrWhiteSpace(uri))
            {
                return(null);
            }
            var username = cipher.Login.Username;

            if (string.IsNullOrWhiteSpace(username))
            {
                return(null);
            }
            var serviceId = new ASCredentialServiceIdentifier(uri, ASCredentialServiceIdentifierType.Url);

            return(new ASPasswordCredentialIdentity(serviceId, username, cipher.Id));
        }