Ejemplo n.º 1
0
        protected internal ApiKeyInfo GenerateApiKeyInfo(ApplicationRegistration.Application app)
        {
            ApiKeyInfo info = new ApiKeyInfo();

            info.ApplicationNameProvider = new StaticApplicationNameProvider(app.Name);
            info.ApplicationClientId     = app.Cuid;
            info.ApiKey = ServiceProxySystem.GenerateId();
            return(info);
        }
Ejemplo n.º 2
0
        protected internal ApiKeyInfo GenerateApiKeyInfo(CoreServices.ApplicationRegistration.Data.Application app)
        {
            ApiKeyInfo info = new ApiKeyInfo
            {
                ApplicationNameProvider = new StaticApplicationNameProvider(app.Name),
                ApplicationClientId     = app.Cuid,
                ApiKey = ServiceProxySystem.GenerateId()
            };

            return(info);
        }
Ejemplo n.º 3
0
        public static ApiKey AddKey(Application app, IUserResolver userResolver, IHttpContext context, Database database = null)
        {
            ApiKey key = app.ApiKeysByApplicationId.AddNew();

            key.ClientId     = GetClientId(app.Name);
            key.Disabled     = false;
            key.SharedSecret = ServiceProxySystem.GenerateId();
            key.CreatedBy    = userResolver.GetUser(context);
            key.CreatedAt    = new Instant();
            key.Save(database);
            return(key);
        }
Ejemplo n.º 4
0
        public void ResetPasswordShouldBeLoginnable()
        {
            string userName = MethodBase.GetCurrentMethod().Name;
            string email    = "*****@*****.**";

            UserTestTools.SignUp(userName, email);
            User user = User.GetByEmail(email);

            Expect.AreEqual(0, user.PasswordResetsByUserId.Count);

            UserManager userMgr = UserTestTools.CreateTestUserManager("Stickerize");

            userMgr.HttpContext         = A.Fake <IHttpContext>();
            userMgr.HttpContext.Request = new TestRequest();

            string password = ServiceProxySystem.GenerateId();
            ForgotPasswordResponse forgot = userMgr.ForgotPassword(email);
            PasswordResetResponse  reset  = userMgr.ResetPassword(password.Sha1(), (string)forgot.Data);
            LoginResponse          login  = userMgr.Login(user.UserName, password.Sha1());

            Expect.IsTrue(login.Success, "Login failed");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new Confirmation with the Created and
        /// Token properties set
        /// </summary>
        /// <returns></returns>
        public static Account Create(User user, string provider, string providerUserId, bool isConfirmed = false, Database db = null)
        {
            DateTime now    = DateTime.UtcNow;
            Account  result = new Account();

            result.CreationDate   = now;
            result.Provider       = provider;
            result.ProviderUserId = providerUserId;
            result.Comment        = "Account for ({0})::confirmed({1})"._Format(user.UserName, isConfirmed ? "Y" : "N");
            if (isConfirmed)
            {
                result.ConfirmationDate = now;
            }

            result.IsConfirmed = isConfirmed;
            result.UserId      = user.Id;
            result.Token       = ServiceProxySystem.GenerateId();
            result.IsConfirmed = false;
            result.Save(db);
            user.AccountsByUserId.Reload();
            return(result);
        }
        public void TimeGenerateVsNewGuid()
        {
            string   generatedId;
            TimeSpan generateTime = Exec.Time(() =>
            {
                generatedId = ServiceProxySystem.GenerateId();
            });

            string   guid;
            TimeSpan guidTime = Exec.Time(() =>
            {
                guid = Guid.NewGuid().ToString();
            });

            string   sha256;
            TimeSpan guidTimeSha256 = Exec.Time(() =>
            {
                sha256 = Guid.NewGuid().ToString().Sha256();
            });

            OutLineFormat("Generate took: {0}", generateTime.ToString());
            OutLineFormat("-NewGuid took: {0}", guidTime.ToString());
            OutLineFormat("HashGuid took: {0}", guidTimeSha256.ToString());
        }
Ejemplo n.º 7
0
 public Client()
 {
     Secret = ServiceProxySystem.GenerateId();
 }
Ejemplo n.º 8
0
 public static string GenerateId()
 {
     return(ServiceProxySystem.GenerateId());
 }