public ClientStore( IInstallationRepository installationRepository, IOrganizationRepository organizationRepository, IUserRepository userRepository, GlobalSettings globalSettings, StaticClientStore staticClientStore, ILicensingService licensingService, ICurrentContext currentContext, IOrganizationUserRepository organizationUserRepository, IProviderUserRepository providerUserRepository, IProviderOrganizationRepository providerOrganizationRepository, IOrganizationApiKeyRepository organizationApiKeyRepository) { _installationRepository = installationRepository; _organizationRepository = organizationRepository; _userRepository = userRepository; _globalSettings = globalSettings; _staticClientStore = staticClientStore; _licensingService = licensingService; _currentContext = currentContext; _organizationUserRepository = organizationUserRepository; _providerUserRepository = providerUserRepository; _providerOrganizationRepository = providerOrganizationRepository; _organizationApiKeyRepository = organizationApiKeyRepository; }
public void BeforeEachTest() { serializer = Serializers.Xml; //Generate keypair var keyPair = LicensingService.GenerateKeypair(); //note:only generate the key pair once per application and store the keys somewhere secure. // keyPair.Save(fileinfo, serializer); // keyPair = KeyPair.Load(fileinfo, serializer) //customised license var number = Rand.Next(); var name = Rand.String.NextText(1, 3); creator = new MyTestLicenseCreator(number, name); //create the licensing service service = LicensingService.Create(keyPair, serializer, creator); //generate license var licensee = Rand.String.NextText(1, 3); const LicenseType LICENSE_TYPE = LicenseType.Full; var expiration = DateTime.MaxValue.AddYears(-50); license = service.GenerateLicense(licensee, LICENSE_TYPE, expiration); }
public static void Main(string[] args) { var parameters = ParseParameters(args); try { var host = new WebHostBuilder() .UseContentRoot(parameters.ContainsKey("d") ? parameters["d"] : Directory.GetCurrentDirectory()) .UseStartup <Startup>() .UseServer(new NoopServer()) .Build(); _logger = host.Services.GetRequiredService <ILogger <Program> >(); _licensingService = host.Services.GetRequiredService <ILicensingService>(); } catch (Exception e) { if (_logger != null) { _logger.LogCritical(1, e, "Error while bootstrapping."); } throw e; } MainAsync(parameters).Wait(); }
public OrganizationsController( IOrganizationRepository organizationRepository, IOrganizationUserRepository organizationUserRepository, IOrganizationConnectionRepository organizationConnectionRepository, ISelfHostedSyncSponsorshipsCommand syncSponsorshipsCommand, ICipherRepository cipherRepository, ICollectionRepository collectionRepository, IGroupRepository groupRepository, IPolicyRepository policyRepository, IPaymentService paymentService, ILicensingService licensingService, IApplicationCacheService applicationCacheService, GlobalSettings globalSettings, IReferenceEventService referenceEventService, IUserService userService) { _organizationRepository = organizationRepository; _organizationUserRepository = organizationUserRepository; _organizationConnectionRepository = organizationConnectionRepository; _syncSponsorshipsCommand = syncSponsorshipsCommand; _cipherRepository = cipherRepository; _collectionRepository = collectionRepository; _groupRepository = groupRepository; _policyRepository = policyRepository; _paymentService = paymentService; _licensingService = licensingService; _applicationCacheService = applicationCacheService; _globalSettings = globalSettings; _referenceEventService = referenceEventService; _userService = userService; }
/// <summary> /// Initializes a new instance of the <see cref="LicenseController"/> class. /// </summary> /// <param name="commandExecutor">The command executor.</param> /// <param name="licensingService">The licensing service.</param> public LicenseController(ICommandExecutor commandExecutor, ILicensingService licensingService) : base(commandExecutor) { Guard.AgainstNullArgument("licensingService", licensingService); this._licensingService = licensingService; }
public ValidateUsersJob( ILicensingService licensingService, ILogger <ValidateUsersJob> logger) : base(logger) { _licensingService = licensingService; }
public UserServiceTests() { _userRepository = Substitute.For <IUserRepository>(); _cipherRepository = Substitute.For <ICipherRepository>(); _organizationUserRepository = Substitute.For <IOrganizationUserRepository>(); _organizationRepository = Substitute.For <IOrganizationRepository>(); _mailService = Substitute.For <IMailService>(); _pushService = Substitute.For <IPushNotificationService>(); _userStore = Substitute.For <IUserStore <User> >(); _optionsAccessor = Substitute.For <IOptions <IdentityOptions> >(); _passwordHasher = Substitute.For <IPasswordHasher <User> >(); _userValidators = new List <IUserValidator <User> >(); _passwordValidators = new List <IPasswordValidator <User> >(); _keyNormalizer = Substitute.For <ILookupNormalizer>(); _errors = new IdentityErrorDescriber(); _services = Substitute.For <IServiceProvider>(); _logger = Substitute.For <ILogger <UserManager <User> > >(); _licenseService = Substitute.For <ILicensingService>(); _eventService = Substitute.For <IEventService>(); _applicationCacheService = Substitute.For <IApplicationCacheService>(); _dataProtectionProvider = Substitute.For <IDataProtectionProvider>(); _paymentService = Substitute.For <IPaymentService>(); _policyRepository = Substitute.For <IPolicyRepository>(); _referenceEventService = Substitute.For <IReferenceEventService>(); _fido2 = Substitute.For <IFido2>(); _currentContext = new CurrentContext(null); _globalSettings = new GlobalSettings(); _organizationService = Substitute.For <IOrganizationService>(); _providerUserRepository = Substitute.For <IProviderUserRepository>(); _sut = new UserService( _userRepository, _cipherRepository, _organizationUserRepository, _organizationRepository, _mailService, _pushService, _userStore, _optionsAccessor, _passwordHasher, _userValidators, _passwordValidators, _keyNormalizer, _errors, _services, _logger, _licenseService, _eventService, _applicationCacheService, _dataProtectionProvider, _paymentService, _policyRepository, _referenceEventService, _fido2, _currentContext, _globalSettings, _organizationService, _providerUserRepository ); }
public ValidateOrganizationsJob( ILicensingService licensingService, ILogger <ValidateOrganizationsJob> logger) : base(logger) { _licensingService = licensingService; }
public UserService( IUserRepository userRepository, ICipherRepository cipherRepository, IOrganizationUserRepository organizationUserRepository, IOrganizationRepository organizationRepository, IU2fRepository u2fRepository, IMailService mailService, IPushNotificationService pushService, IUserStore <User> store, IOptions <IdentityOptions> optionsAccessor, IPasswordHasher <User> passwordHasher, IEnumerable <IUserValidator <User> > userValidators, IEnumerable <IPasswordValidator <User> > passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger <UserManager <User> > logger, ILicensingService licenseService, IEventService eventService, IApplicationCacheService applicationCacheService, IDataProtectionProvider dataProtectionProvider, IPaymentService paymentService, IPolicyRepository policyRepository, IReferenceEventService referenceEventService, CurrentContext currentContext, GlobalSettings globalSettings) : base( store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger) { _userRepository = userRepository; _cipherRepository = cipherRepository; _organizationUserRepository = organizationUserRepository; _organizationRepository = organizationRepository; _u2fRepository = u2fRepository; _mailService = mailService; _pushService = pushService; _identityOptions = optionsAccessor?.Value ?? new IdentityOptions(); _identityErrorDescriber = errors; _passwordHasher = passwordHasher; _passwordValidators = passwordValidators; _licenseService = licenseService; _eventService = eventService; _applicationCacheService = applicationCacheService; _paymentService = paymentService; _policyRepository = policyRepository; _organizationServiceDataProtector = dataProtectionProvider.CreateProtector( "OrganizationServiceDataProtector"); _referenceEventService = referenceEventService; _currentContext = currentContext; _globalSettings = globalSettings; }
public OrganizationLicense(Organization org, BillingInfo billingInfo, Guid installationId, ILicensingService licenseService) { Version = 2; LicenseKey = org.LicenseKey; InstallationId = installationId; Id = org.Id; Name = org.Name; BillingEmail = org.BillingEmail; BusinessName = org.BusinessName; Enabled = org.Enabled; Plan = org.Plan; PlanType = org.PlanType; Seats = org.Seats; MaxCollections = org.MaxCollections; UseGroups = org.UseGroups; UseDirectory = org.UseDirectory; UseTotp = org.UseTotp; MaxStorageGb = org.MaxStorageGb; SelfHost = org.SelfHost; UsersGetPremium = org.UsersGetPremium; Issued = DateTime.UtcNow; if (billingInfo?.Subscription == null) { Expires = Refresh = Issued.AddDays(7); Trial = true; } else if (billingInfo.Subscription.TrialEndDate.HasValue && billingInfo.Subscription.TrialEndDate.Value > DateTime.UtcNow) { Expires = Refresh = billingInfo.Subscription.TrialEndDate.Value; Trial = true; } else { if (org.ExpirationDate.HasValue && org.ExpirationDate.Value < DateTime.UtcNow) { // expired Expires = Refresh = org.ExpirationDate.Value; } else if (billingInfo?.Subscription?.PeriodDuration != null && billingInfo.Subscription.PeriodDuration > TimeSpan.FromDays(180)) { Refresh = DateTime.UtcNow.AddDays(30); Expires = billingInfo?.Subscription.PeriodEndDate.Value.AddDays(60); } else { Expires = org.ExpirationDate.HasValue ? org.ExpirationDate.Value.AddMonths(11) : Issued.AddYears(1); Refresh = DateTime.UtcNow - Expires > TimeSpan.FromDays(30) ? DateTime.UtcNow.AddDays(30) : Expires; } Trial = false; } Hash = Convert.ToBase64String(ComputeHash()); Signature = Convert.ToBase64String(licenseService.SignLicense(this)); }
/// <summary> /// The on service connected. /// </summary> /// <param name="name"> /// The name. /// </param> /// <param name="service"> /// The service. /// </param> public void OnServiceConnected(ComponentName name, IBinder service) { lock (this.locker) { this.licensingService = LicensingServiceStub.AsInterface(service); this.RunChecks(); } }
/// <summary> /// The on service disconnected. /// </summary> /// <param name="name"> /// The name. /// </param> public void OnServiceDisconnected(ComponentName name) { lock (this.locker) { // Called when the connection with the service has been // unexpectedly disconnected. That is, Market crashed. // If there are any checks in progress, the timeouts will handle them. Debug.WriteLine("Service unexpectedly disconnected."); this.licensingService = null; } }
public ProfileService( IUserRepository userRepository, IUserService userService, IOrganizationUserRepository organizationUserRepository, ILicensingService licensingService) { _userRepository = userRepository; _userService = userService; _organizationUserRepository = organizationUserRepository; _licensingService = licensingService; }
public ProfileService( IUserService userService, IOrganizationUserRepository organizationUserRepository, ILicensingService licensingService, ICurrentContext currentContext) { _userService = userService; _organizationUserRepository = organizationUserRepository; _licensingService = licensingService; _currentContext = currentContext; }
/// <summary> /// The as interface. /// </summary> /// <param name="obj"> /// The obj. /// </param> /// <returns> /// </returns> public static ILicensingService AsInterface(IBinder obj) { ILicensingService result = null; if (obj != null) { var iin = obj.QueryLocalInterface(Descriptor) as ILicensingService; result = iin ?? new Proxy(obj); } return(result); }
public ProfileService( IUserRepository userRepository, IUserService userService, IOrganizationUserRepository organizationUserRepository, ILicensingService licensingService, IOptions <IdentityOptions> identityOptionsAccessor) { _userRepository = userRepository; _userService = userService; _organizationUserRepository = organizationUserRepository; _licensingService = licensingService; _identityOptions = identityOptionsAccessor?.Value ?? new IdentityOptions(); }
public AccountsController( IUserService userService, ICipherService cipherService, IOrganizationUserRepository organizationUserRepository, ILicensingService licenseService, GlobalSettings globalSettings) { _userService = userService; _cipherService = cipherService; _organizationUserRepository = organizationUserRepository; _licenseService = licenseService; _globalSettings = globalSettings; }
public SelfHostedSponsorshipSyncJob( IServiceProvider serviceProvider, IOrganizationRepository organizationRepository, IOrganizationConnectionRepository organizationConnectionRepository, ILicensingService licensingService, ILogger <SelfHostedSponsorshipSyncJob> logger, GlobalSettings globalSettings) : base(logger) { _serviceProvider = serviceProvider; _organizationRepository = organizationRepository; _organizationConnectionRepository = organizationConnectionRepository; _licensingService = licensingService; _globalSettings = globalSettings; }
public LicensesController( ILicensingService licensingService, IUserRepository userRepository, IUserService userService, IOrganizationRepository organizationRepository, IOrganizationService organizationService, ICurrentContext currentContext) { _licensingService = licensingService; _userRepository = userRepository; _userService = userService; _organizationRepository = organizationRepository; _organizationService = organizationService; _currentContext = currentContext; }
public UserLicense(User user, ILicensingService licenseService) { LicenseKey = user.LicenseKey; Id = user.Id; Name = user.Name; Email = user.Email; Version = 1; Premium = user.Premium; MaxStorageGb = user.MaxStorageGb; Issued = DateTime.UtcNow; Expires = user.PremiumExpirationDate?.AddDays(7); Refresh = user.PremiumExpirationDate?.Date; Trial = false; Hash = Convert.ToBase64String(ComputeHash()); Signature = Convert.ToBase64String(licenseService.SignLicense(this)); }
/// <summary> /// Unbinds service if necessary and removes reference to it. /// </summary> private void CleanupService() { if (this.licensingService != null) { try { this.context.UnbindService(this); } catch { // Somehow we've already been unbound. This is a non-fatal error. Debug.WriteLine("Unable to unbind from licensing service (already unbound)."); } this.licensingService = null; } }
public OrganizationConnectionsController( ICreateOrganizationConnectionCommand createOrganizationConnectionCommand, IUpdateOrganizationConnectionCommand updateOrganizationConnectionCommand, IDeleteOrganizationConnectionCommand deleteOrganizationConnectionCommand, IOrganizationConnectionRepository organizationConnectionRepository, ICurrentContext currentContext, IGlobalSettings globalSettings, ILicensingService licensingService) { _createOrganizationConnectionCommand = createOrganizationConnectionCommand; _updateOrganizationConnectionCommand = updateOrganizationConnectionCommand; _deleteOrganizationConnectionCommand = deleteOrganizationConnectionCommand; _organizationConnectionRepository = organizationConnectionRepository; _currentContext = currentContext; _globalSettings = globalSettings; _licensingService = licensingService; }
public UserLicense(User user, BillingInfo billingInfo, ILicensingService licenseService) { LicenseKey = user.LicenseKey; Id = user.Id; Name = user.Name; Email = user.Email; Version = 1; Premium = user.Premium; MaxStorageGb = user.MaxStorageGb; Issued = DateTime.UtcNow; Expires = billingInfo?.UpcomingInvoice?.Date?.AddDays(7); Refresh = billingInfo?.UpcomingInvoice?.Date; Trial = (billingInfo?.Subscription?.TrialEndDate.HasValue ?? false) && billingInfo.Subscription.TrialEndDate.Value > DateTime.UtcNow; Hash = Convert.ToBase64String(ComputeHash()); Signature = Convert.ToBase64String(licenseService.SignLicense(this)); }
public AccountsController( IUserService userService, IUserRepository userRepository, ICipherRepository cipherRepository, IFolderRepository folderRepository, ICipherService cipherService, IOrganizationUserRepository organizationUserRepository, ILicensingService licenseService, IPaymentService paymentService, GlobalSettings globalSettings) { _userService = userService; _userRepository = userRepository; _cipherRepository = cipherRepository; _folderRepository = folderRepository; _cipherService = cipherService; _organizationUserRepository = organizationUserRepository; _licenseService = licenseService; _paymentService = paymentService; _globalSettings = globalSettings; }
public UserLicense(User user, SubscriptionInfo subscriptionInfo, ILicensingService licenseService, int?version = null) { LicenseKey = user.LicenseKey; Id = user.Id; Name = user.Name; Email = user.Email; Version = version.GetValueOrDefault(1); Premium = user.Premium; MaxStorageGb = user.MaxStorageGb; Issued = DateTime.UtcNow; Expires = subscriptionInfo?.UpcomingInvoice?.Date != null? subscriptionInfo.UpcomingInvoice.Date.Value.AddDays(7) : user.PremiumExpirationDate?.AddDays(7); Refresh = subscriptionInfo?.UpcomingInvoice?.Date; Trial = (subscriptionInfo?.Subscription?.TrialEndDate.HasValue ?? false) && subscriptionInfo.Subscription.TrialEndDate.Value > DateTime.UtcNow; Hash = Convert.ToBase64String(ComputeHash()); Signature = Convert.ToBase64String(licenseService.SignLicense(this)); }
public OrganizationLicense(Organization org, SubscriptionInfo subscriptionInfo, Guid installationId, ILicensingService licenseService, int?version = null) { Version = version.GetValueOrDefault(7); // TODO: bump to version 8 LicenseKey = org.LicenseKey; InstallationId = installationId; Id = org.Id; Name = org.Name; BillingEmail = org.BillingEmail; BusinessName = org.BusinessName; Enabled = org.Enabled; Plan = org.Plan; PlanType = org.PlanType; Seats = org.Seats; MaxCollections = org.MaxCollections; UsePolicies = org.UsePolicies; UseSso = org.UseSso; UseGroups = org.UseGroups; UseEvents = org.UseEvents; UseDirectory = org.UseDirectory; UseTotp = org.UseTotp; Use2fa = org.Use2fa; UseApi = org.UseApi; UseResetPassword = org.UseResetPassword; MaxStorageGb = org.MaxStorageGb; SelfHost = org.SelfHost; UsersGetPremium = org.UsersGetPremium; Issued = DateTime.UtcNow; if (subscriptionInfo?.Subscription == null) { if (org.PlanType == PlanType.Custom && org.ExpirationDate.HasValue) { Expires = Refresh = org.ExpirationDate.Value; Trial = false; } else { Expires = Refresh = Issued.AddDays(7); Trial = true; } } else if (subscriptionInfo.Subscription.TrialEndDate.HasValue && subscriptionInfo.Subscription.TrialEndDate.Value > DateTime.UtcNow) { Expires = Refresh = subscriptionInfo.Subscription.TrialEndDate.Value; Trial = true; } else { if (org.ExpirationDate.HasValue && org.ExpirationDate.Value < DateTime.UtcNow) { // expired Expires = Refresh = org.ExpirationDate.Value; } else if (subscriptionInfo?.Subscription?.PeriodDuration != null && subscriptionInfo.Subscription.PeriodDuration > TimeSpan.FromDays(180)) { Refresh = DateTime.UtcNow.AddDays(30); Expires = subscriptionInfo?.Subscription.PeriodEndDate.Value.AddDays(60); } else { Expires = org.ExpirationDate.HasValue ? org.ExpirationDate.Value.AddMonths(11) : Issued.AddYears(1); Refresh = DateTime.UtcNow - Expires > TimeSpan.FromDays(30) ? DateTime.UtcNow.AddDays(30) : Expires; } Trial = false; } Hash = Convert.ToBase64String(ComputeHash()); Signature = Convert.ToBase64String(licenseService.SignLicense(this)); }
/// <summary> /// Initializes a new instance of the <see cref="LoadLicenseStartable"/> class. /// </summary> /// <param name="licensingService">The licensing service.</param> public LoadLicenseStartable(ILicensingService licensingService) { Guard.AgainstNullArgument("licensingService", licensingService); this._licensingService = licensingService; }
public GetLicenseInfoQueryHandler(ILicensingService licensingService) { _licensingService = licensingService; }