public async Task <bool> LoginUser(string userName, string password)
        {
            var result = false;

            try
            {
                var api = new IdentityApi(
                    "https://localhost:6001",
                    await TokenService.Instance.GetAccessTokenAsync());

                var validUser = await api.ValidateUser(userName, password);

                if (validUser)
                {
                    var authUser = await api.GetAuthenticatedUser(userName);

                    if (authUser != null)
                    {
                        this.CurrentPrincipal = authUser;
                        LoggedIn?.Invoke(this, EventArgs.Empty);
                        result = true;
                    }
                }
                else
                {
                    LoginFailed?.Invoke(this, EventArgs.Empty);
                }
            }
            catch (Exception e)
            {
                this.Log().LogError(e.Message);
            }

            return(result);
        }
        private IdentityApi BuildIdentityClient(Row row)
        {
            if (row == null)
            {
                return(null);
            }

            IdentityApi identityApi = new IdentityApi
            {
                Code        = row.GetValue <string>(IdentityApiConstant.COLUMNS_CODE),
                Description = row.GetValue <string>(IdentityApiConstant.COLUMNS_DESCRIPTION),
                Claims      = row.GetValue <ICollection <string> >(IdentityApiConstant.COLUMNS_CLAIMS)
            };

            return(identityApi);
        }
Beispiel #3
0
        public OkraApi(string accessToken, bool useSandBox)
        {
            if (string.IsNullOrWhiteSpace(accessToken))
            {
                throw new ArgumentException("Okra api token cannot be empty", nameof(accessToken));
            }

            var baseUrl = useSandBox ? "https://api.okra.ng/sandbox/v1/" : "https://api.okra.ng/v1/";

            _client = CreateClient(baseUrl, accessToken);

            Auth         = new AuthApi(this);
            Balance      = new BalanceApi(this);
            Identity     = new IdentityApi(this);
            Income       = new IncomeApi(this);
            Transactions = new TransactionsApi(this);
        }
Beispiel #4
0
 public IdentityData(IdentityApi data)
 {
     Title          = data.Title;
     FirstName      = data.FirstName;
     MiddleName     = data.MiddleName;
     LastName       = data.LastName;
     Address1       = data.Address1;
     Address2       = data.Address2;
     Address3       = data.Address3;
     City           = data.City;
     State          = data.State;
     PostalCode     = data.PostalCode;
     Country        = data.Country;
     Company        = data.Company;
     Email          = data.Email;
     Phone          = data.Phone;
     SSN            = data.SSN;
     Username       = data.Username;
     PassportNumber = data.PassportNumber;
     LicenseNumber  = data.LicenseNumber;
 }
        // GET: /IdentityInfo/
        public async Task <ActionResult> Index()
        {
            var xeroToken  = TokenUtilities.GetStoredToken();
            var utcTimeNow = DateTime.UtcNow;

            if (utcTimeNow > xeroToken.ExpiresAtUtc)
            {
                var client = new XeroClient(XeroConfig.Value, httpClientFactory);
                xeroToken = (XeroOAuth2Token)await client.RefreshAccessTokenAsync(xeroToken);

                TokenUtilities.StoreToken(xeroToken);
            }

            string accessToken = xeroToken.AccessToken;

            var IdentityApi = new IdentityApi();
            var response    = await IdentityApi.GetConnectionsAsync(accessToken);

            var connections = response;

            return(View(connections));
        }
        public async Task <ActionResult> Delete(string connectionId)
        {
            var xeroToken  = TokenUtilities.GetStoredToken();
            var utcTimeNow = DateTime.UtcNow;

            if (utcTimeNow > xeroToken.ExpiresAtUtc)
            {
                var client = new XeroClient(XeroConfig.Value, httpClientFactory);
                xeroToken = (XeroOAuth2Token)await client.RefreshAccessTokenAsync(xeroToken);

                TokenUtilities.StoreToken(xeroToken);
            }

            string accessToken      = xeroToken.AccessToken;
            Guid   connectionIdGuid = Guid.Parse(connectionId);

            var IdentityApi = new IdentityApi();
            await IdentityApi.DeleteConnectionAsync(accessToken, connectionIdGuid);

            TokenUtilities.DestroyToken();

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #7
0
        public CipherRequest(Cipher cipher)
        {
            Type                  = cipher.Type;
            OrganizationId        = cipher.OrganizationId;
            FolderId              = cipher.FolderId;
            Name                  = cipher.Name?.EncryptedString;
            Notes                 = cipher.Notes?.EncryptedString;
            Favorite              = cipher.Favorite;
            LastKnownRevisionDate = cipher.RevisionDate;
            Reprompt              = cipher.Reprompt;

            switch (Type)
            {
            case CipherType.Login:
                Login = new LoginApi
                {
                    Uris = cipher.Login.Uris?.Select(
                        u => new LoginUriApi {
                        Match = u.Match, Uri = u.Uri?.EncryptedString
                    }).ToList(),
                    Username             = cipher.Login.Username?.EncryptedString,
                    Password             = cipher.Login.Password?.EncryptedString,
                    PasswordRevisionDate = cipher.Login.PasswordRevisionDate,
                    Totp = cipher.Login.Totp?.EncryptedString
                };
                break;

            case CipherType.Card:
                Card = new CardApi
                {
                    CardholderName = cipher.Card.CardholderName?.EncryptedString,
                    Brand          = cipher.Card.Brand?.EncryptedString,
                    Number         = cipher.Card.Number?.EncryptedString,
                    ExpMonth       = cipher.Card.ExpMonth?.EncryptedString,
                    ExpYear        = cipher.Card.ExpYear?.EncryptedString,
                    Code           = cipher.Card.Code?.EncryptedString
                };
                break;

            case CipherType.Identity:
                Identity = new IdentityApi
                {
                    Title          = cipher.Identity.Title?.EncryptedString,
                    FirstName      = cipher.Identity.FirstName?.EncryptedString,
                    MiddleName     = cipher.Identity.MiddleName?.EncryptedString,
                    LastName       = cipher.Identity.LastName?.EncryptedString,
                    Address1       = cipher.Identity.Address1?.EncryptedString,
                    Address2       = cipher.Identity.Address2?.EncryptedString,
                    Address3       = cipher.Identity.Address3?.EncryptedString,
                    City           = cipher.Identity.City?.EncryptedString,
                    State          = cipher.Identity.State?.EncryptedString,
                    PostalCode     = cipher.Identity.PostalCode?.EncryptedString,
                    Country        = cipher.Identity.Country?.EncryptedString,
                    Company        = cipher.Identity.Company?.EncryptedString,
                    Email          = cipher.Identity.Email?.EncryptedString,
                    Phone          = cipher.Identity.Phone?.EncryptedString,
                    SSN            = cipher.Identity.SSN?.EncryptedString,
                    Username       = cipher.Identity.Username?.EncryptedString,
                    PassportNumber = cipher.Identity.PassportNumber?.EncryptedString,
                    LicenseNumber  = cipher.Identity.LicenseNumber?.EncryptedString
                };
                break;

            case CipherType.SecureNote:
                SecureNote = new SecureNoteApi
                {
                    Type = cipher.SecureNote.Type
                };
                break;

            default:
                break;
            }

            Fields = cipher.Fields?.Select(f => new FieldApi
            {
                Type     = f.Type,
                Name     = f.Name?.EncryptedString,
                Value    = f.Value?.EncryptedString,
                LinkedId = f.LinkedId,
            }).ToList();

            PasswordHistory = cipher.PasswordHistory?.Select(ph => new PasswordHistoryRequest
            {
                Password     = ph.Password?.EncryptedString,
                LastUsedDate = ph.LastUsedDate
            }).ToList();

            if (cipher.Attachments != null)
            {
                Attachments  = new Dictionary <string, string>();
                Attachments2 = new Dictionary <string, AttachmentRequest>();
                foreach (var attachment in cipher.Attachments)
                {
                    var fileName = attachment.FileName?.EncryptedString;
                    Attachments.Add(attachment.Id, fileName);
                    Attachments2.Add(attachment.Id, new AttachmentRequest
                    {
                        FileName = fileName,
                        Key      = attachment.Key?.EncryptedString
                    });
                }
            }
        }
Beispiel #8
0
 public void Init()
 {
     client   = new ApiClient(subdomain, clientId, clientSecret: clientSecret);
     instance = client.Identity;
 }
Beispiel #9
0
 public void Init()
 {
     instance = new IdentityApi();
 }
Beispiel #10
0
 /// <summary>
 /// Creates an instance of the LoanPayClient
 /// </summary>
 /// <param name="httpClient">Sets the HttpClient to be used by the LoanPayClient</param>
 /// <param name="environmentManager">Sets the environment to be used by the LoanPayClient</param>
 /// <param name="identityClientId">Sets the Identity Client Id to be used by the LoanPayClient</param>
 /// <param name="identityClientSecret">Sets the Identity Client Secret to be used by the LoanPayClient</param>
 public Client(HttpClient httpClient, IEnvironmentManager environmentManager, string identityClientId, string identityClientSecret)
 {
     IdentityApi = new IdentityApi(httpClient, environmentManager, identityClientId, identityClientSecret);
     LoanPayApi  = new LoanPayApi(httpClient, environmentManager);
     TokenApi    = new TokenApi(httpClient, environmentManager);
 }