コード例 #1
0
		public AccountController(UserManager<ApplicationUser> userManager, IUserAuthentication userAuthentication, IEmailService<Email> emailService, ILogger logger)
		{
			UserManager = userManager;
			_userAuthentication = userAuthentication;
			_emailService = emailService;
			_logger = logger;
		}
コード例 #2
0
ファイル: UserTasks.cs プロジェクト: scottccoates/CliqFlip
 public UserTasks(
     IInterestTasks interestTasks,
     IImageProcessor imageProcessor,
     IFileUploadService fileUploadService,
     IWebContentService webContentService,
     IFeedFinder feedFinder,
     IUserAuthentication userAuthentication,
     IConversationRepository conversationRepository,
     IEmailService emailService,
     ILocationService locationService,
     IUserRepository userRepository,
     IPageParsingService pageParsingService, IUserInterestTasks userInterestTasks)
 {
     _interestTasks = interestTasks;
     _imageProcessor = imageProcessor;
     _fileUploadService = fileUploadService;
     _webContentService = webContentService;
     _feedFinder = feedFinder;
     _userAuthentication = userAuthentication;
     _conversationRepository = conversationRepository;
     _emailService = emailService;
     _locationService = locationService;
     _userRepository = userRepository;
     _pageParsingService = pageParsingService;
     _userInterestTasks = userInterestTasks;
 }
コード例 #3
0
        public async Task <IUserAuthentication> AddNew(IUserAuthentication entity)
        {
            TUserAuthentication tEntity = entity as TUserAuthentication;

            var errors = await this.ValidateEntityToAdd(tEntity);

            if (errors.Count() > 0)
            {
                await this.ThrowEntityException(errors);
            }

            try
            {
                this.StartTransaction();
                entity.Verified         = false;
                entity.VerificationCode = _codeGenerator.GenerateCode();
                entity.CodeExpiration   = DateTime.Now;
                var savedEntity = await base.AddNew(tEntity);

                this.CommitTransaction();
                /*write the email sending code*/

                return(savedEntity);
            }
            catch (PostgresException ex)
            {
                throw new EntityUpdateException(ex);
            }
            catch
            {
                throw;
            }
        }
コード例 #4
0
 public StepDefinitions()
 {
     var mock = new Moq.Mock<IUserAuthentication>();
     mock.Expect(x => x.IsValidLogin("admin", "password")).Returns(true);
     //mock.Expect(x => x.IsValidLogin(It.IsAny<string>(), It.IsAny<string>())).Returns(false);
     _auth = mock.Object;
 }
コード例 #5
0
        public static bool SetUserPassword(string AUsername, string APassword, bool APasswordNeedsChanged)
        {
            string UserAuthenticationMethod = TAppSettingsManager.GetValue("UserAuthenticationMethod", "OpenPetraDBSUser", false);

            if (UserAuthenticationMethod == "OpenPetraDBSUser")
            {
                TPetraPrincipal tempPrincipal;
                SUserRow        UserDR    = TUserManagerWebConnector.LoadUser(AUsername.ToUpper(), out tempPrincipal);
                SUserTable      UserTable = (SUserTable)UserDR.Table;

                Random r = new Random();
                UserDR.PasswordSalt = r.Next(1000000000).ToString();
                UserDR.PasswordHash = TUserManagerWebConnector.CreateHashOfPassword(String.Concat(APassword,
                                                                                                  UserDR.PasswordSalt), "SHA1");
                UserDR.PasswordNeedsChange = APasswordNeedsChanged;

                TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable);
                SUserAccess.SubmitChanges(UserTable, Transaction);

                DBAccess.GDBAccessObj.CommitTransaction();

                return(true);
            }
            else
            {
                IUserAuthentication auth = TUserManagerWebConnector.LoadAuthAssembly(UserAuthenticationMethod);

                return(auth.SetPassword(AUsername, APassword));
            }
        }
コード例 #6
0
 public UserDetailsController(IUserDetails UserDetails, ICompanyDetails CompanyDetails, IRole Role, IUserAuthentication UserAuthentication)
 {
     _IUserDetails        = UserDetails;
     _ICompanyDetails     = CompanyDetails;
     _IRole               = Role;
     _IUserAuthentication = UserAuthentication;
 }
コード例 #7
0
ファイル: UserManagement.cs プロジェクト: hoangduit/openpetra
        public static bool PasswordAuthentication(String AUserID, String APassword)
        {
            TPetraPrincipal PetraPrincipal = null;

            SUserRow UserDR = TUserManagerWebConnector.LoadUser(AUserID, out PetraPrincipal);
            string   UserAuthenticationMethod = TAppSettingsManager.GetValue("UserAuthenticationMethod", "OpenPetraDBSUser", false);

            if (UserAuthenticationMethod == "OpenPetraDBSUser")
            {
                if (TUserManagerWebConnector.CreateHashOfPassword(String.Concat(APassword,
                                                                                UserDR.PasswordSalt)) != UserDR.PasswordHash)
                {
                    return(false);
                }
            }
            else
            {
                IUserAuthentication auth = TUserManagerWebConnector.LoadAuthAssembly(UserAuthenticationMethod);

                string ErrorMessage;

                if (!auth.AuthenticateUser(AUserID, APassword, out ErrorMessage))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #8
0
 public UsersController(IUsersService usersService,
                        IUserAuthentication authentication,
                        ILoginService loginService)
     : base(authentication, loginService)
 {
     this.usersService = usersService;
 }
コード例 #9
0
        private void SaveExceptionToDatabase(Exception httpException)
        {
            var exceptionGuid = Guid.NewGuid();
            IExceptionRepository      exceptionRepository      = DependencyResolver.Current.GetService(typeof(IExceptionRepository)) as IExceptionRepository;
            IExceptionEventRepository exceptionEventRepository = DependencyResolver.Current.GetService(typeof(IExceptionEventRepository)) as IExceptionEventRepository;
            IUserAuthentication       authentication           = DependencyResolver.Current.GetService(typeof(IUserAuthentication)) as IUserAuthentication;
            ISessionProvider          sessionProvider          = DependencyResolver.Current.GetService(typeof(ISessionProvider)) as ISessionProvider;
            var exceptions = this.GetAllExceptions(httpException)
                             .ToList()
                             .Select(
                exception =>
                new ItanException
            {
                Message    = exception.Message,
                Source     = exception.Source,
                Stacktrace = exception.StackTrace,
                Typeof     = exception.GetType().ToString(),
                ErrorId    = exceptionGuid,
                UserId     = authentication.CurrentUserIsAuthenticated() ? sessionProvider.GetCurrentUserId() : 0
            });

            var eventItanExceptions = exceptions.Select(e => new EventItanException()
            {
                ErrorId = exceptionGuid, ItanException = e
            });

            //exceptionRepository.SaveToDatabase(exceptions);
            exceptionEventRepository.SaveToDatabase(eventItanExceptions);
        }
コード例 #10
0
 public UsersController(IUsersService usersService,
                        IUserAuthentication authentication,
                        ILoginService loginService,
                        ISessionProvider sessionProvider)
     : base(authentication, loginService, sessionProvider)
 {
     this.usersService = usersService;
 }
コード例 #11
0
ファイル: Smtp.cs プロジェクト: martinbergpetersen/mail
        public Smtp(IServerSetting settings, IUserAuthentication user, MimeMessage mimeMessage)
        {
            _client = new SmtpClient();

            _mimeMessage = mimeMessage;
            _server      = settings;
            _user        = user;
        }
コード例 #12
0
 public UserSubscriptionService(IUsersSubscriptionRepository userSubscriptionsRepository,
     IUserSubscriptionEntryToReadRepository userSubscriptionsEntryToReadRepository,
     IUserAuthentication authentication)
 {
     this.userSubscriptionsRepository = userSubscriptionsRepository;
     this.userSubscriptionsEntryToReadRepository = userSubscriptionsEntryToReadRepository;
     this.authentication = authentication;
 }
コード例 #13
0
 public FriendlyImageUrlStrategy(
     IAlbumFacade gallery,
     IUserAuthentication authentication
     )
 {
     this.gallery = gallery;
     this.authentication = authentication;
 }
コード例 #14
0
 public AccountController(
     IUserAuthentication authentication,
     ILoginService loginService,
     IAccountService accountService)
     : base(authentication, loginService)
 {
     this.accountService = accountService;
 }
コード例 #15
0
 public UsersController(IUsersService usersService,
                        IUserAuthentication authentication,
                        ILoginService loginService,
                        ISessionProvider sessionProvider)
     : base(authentication, loginService, sessionProvider)
 {
     this.usersService = usersService;
 }
コード例 #16
0
 public OpmlImporterController(
     IUserAuthentication authentication,
     ILoginService loginService,
     IOpmlImporterService opmlImporterService)
     : base(authentication, loginService)
 {
     this.opmlImporterService = opmlImporterService;
 }
コード例 #17
0
 public OpmlImporterController(
     IUserAuthentication authentication,
     ILoginService loginService,
     ISessionProvider sessionProvider,
     IOpmlImporterService opmlImporterService) : base(authentication, loginService, sessionProvider)
 {
     this.opmlImporterService = opmlImporterService;
 }
コード例 #18
0
 public GivenAnUserAuthentication()
 {
     UserRepository     = new Mock <IUserRepository>();
     UnitOfWork         = new Mock <IUnitOfWork>();
     EncriptionService  = new Mock <IEncryptionService>();
     DomainNotification = new Mock <INotifiable <DomainNotification> >();
     UserAuthentication = new UserAuthentication(UnitOfWork.Object, UserRepository.Object, DomainNotification.Object, EncriptionService.Object);
 }
コード例 #19
0
 public StreamController(
    IUserAuthentication authentication,
    ILoginService loginService,
    IRssSubscriptionService rssSubscriptionService)
     : base(authentication, loginService)
 {
     this.rssSubscriptionService = rssSubscriptionService;
 }
コード例 #20
0
 public StreamController(
     IUserAuthentication authentication,
     ILoginService loginService,
     ISessionProvider sessionProvider,
     IRssSubscriptionService rssSubscriptionService)
     : base(authentication, loginService, sessionProvider)
 {
     this.rssSubscriptionService = rssSubscriptionService;
 }
コード例 #21
0
 public AccountController(
     IUserAuthentication authentication,
     ILoginService loginService,
     ISessionProvider sessionProvider,
     IAccountService accountService)
     : base(authentication, loginService, sessionProvider)
 {
     this.accountService = accountService;
 }
コード例 #22
0
 public HomeController(
     IUserAuthentication authentication,
     ILoginService loginService,
     ISessionProvider sessionProvider,
     IRssChannelsRepository rssRepository)
     : base(authentication, loginService, sessionProvider)
 {
     this.rssRepository = rssRepository;
 }
コード例 #23
0
 public HomeController(
     IUserAuthentication authentication,
     ILoginService loginService,
     ISessionProvider sessionProvider,
     IRssChannelsRepository rssRepository)
     : base(authentication, loginService, sessionProvider)
 {
     this.rssRepository = rssRepository;
 }
コード例 #24
0
 public SignInPageViewModel(INavigationService navigationService,
                            IUserAuthentication userAuthentication,
                            IPageDialogService dialogService,
                            IAuthorizationService authorization)
 {
     _navigationService  = navigationService;
     _userAuthentication = userAuthentication;
     _dialogService      = dialogService;
     _authorization      = authorization;
 }
コード例 #25
0
 public UsersService(IUserRepository usersRepository,
                     IUsersSubscriptionRepository usersSubscriptionRepository,
                     IUserAuthentication authentication,
                     IMapper mapper)
 {
     this.usersRepository = usersRepository;
     this.usersSubscriptionRepository = usersSubscriptionRepository;
     this.authentication = authentication;
     this.mapper = mapper;
 }
コード例 #26
0
 public AdminController(
     IUserAuthentication authentication,
     ILoginService loginService,
     IAdminService adminService,
     IUpdateService updateService)
     : base(authentication, loginService)
 {
     this.adminService = adminService;
     this.updateService = updateService;
 }
コード例 #27
0
 public PersonSubscriptionHandler(
     IRssEventRepository rssEventsRepository,
     IUsersSubscriptionRepository usersSubscriptionRepository,
     IMapper mapper,
     IUserAuthentication authentication)
 {
     this.rssEventsRepository = rssEventsRepository;
     this.usersSubscriptionRepository = usersSubscriptionRepository;
     this.mapper = mapper;
     this.authentication = authentication;
 }
コード例 #28
0
 public OpmlImporterService(
     IRssChannelsSubscriptionsRepository rssSubscriptionsRepository,
     IRssChannelsRepository rssChannelsRepository,
     IOpmlReader opmlHandler,
     IUserAuthentication authentication)
 {
     this.rssSubscriptionsRepository = rssSubscriptionsRepository;
     this.rssChannelsRepository = rssChannelsRepository;
     this.opmlHandler = opmlHandler;
     this.authentication = authentication;
 }
コード例 #29
0
 public RssChannelController(
     IUserAuthentication authentication,
     ILoginService loginService,
     IRssChannelsService rssChannelsService,
     IRssSubscriptionService rssSubscriptionService,
     IUserSubscriptionService userSubscriptionServiceService)
     : base(authentication, loginService)
 {
     this.rssChannelsService = rssChannelsService;
     this.rssSubscriptionService = rssSubscriptionService;
     this.userSubscriptionServiceService = userSubscriptionServiceService;
 }
コード例 #30
0
ファイル: ImageController.cs プロジェクト: ashmind/gallery
 public ImageController(
     PreviewFacade preview,
     IImageFormat[] formats,
     IUserAuthentication authentication,
     IImageRequestStrategy strategy
     )
     : base(authentication)
 {
     this.preview = preview;
     this.formats = formats;
     this.strategy = strategy;
 }
コード例 #31
0
 public RssSubscriptionHandler(
     IRssChannelsSubscriptionsRepository rssSubscriptionsRepository,
     IRssEntriesToReadRepository rssToReadRepository,
     IMapper mapper,
     IRssEventRepository rssEventsRepository,
     IUserAuthentication authentication)
 {
     this.rssSubscriptionsRepository = rssSubscriptionsRepository;
     this.rssToReadRepository = rssToReadRepository;
     this.mapper = mapper;
     this.rssEventsRepository = rssEventsRepository;
     this.authentication = authentication;
 }
コード例 #32
0
 public RssChannelController(
     IUserAuthentication authentication,
     ILoginService loginService,
     ISessionProvider sessionProvider,
     IRssChannelsService rssChannelsService,
     IRssSubscriptionService rssSubscriptionService,
     IUserSubscriptionService userSubscriptionServiceService)
     : base(authentication, loginService, sessionProvider)
 {
     this.rssChannelsService             = rssChannelsService;
     this.rssSubscriptionService         = rssSubscriptionService;
     this.userSubscriptionServiceService = userSubscriptionServiceService;
 }
コード例 #33
0
ファイル: AlbumController.cs プロジェクト: ashmind/gallery
 public AlbumController(
     IAlbumFacade gallery,
     IAuthorizationService authorization,
     IUserAuthentication authentication,
     IImageRequestStrategy requestStrategy,
     ILocation dataLocation
     )
     : base(authentication)
 {
     this.gallery = gallery;
     this.authorization = authorization;
     this.requestStrategy = requestStrategy;
     this.zipLocation = dataLocation.GetLocation("zips", ActionIfMissing.CreateNew);
 }
コード例 #34
0
 public UserController(
     IUserAuthentication repUserAuth,
     IUser repUser,
     IAnnualBudget repAnnualBudget,
     IIRASPermission repIRASPermission,
     IDepreciation repDepreciation
     )
 {
     _repUserAuth       = repUserAuth;
     _repUser           = repUser;
     _repAnnualBudget   = repAnnualBudget;
     _repIRASPermission = repIRASPermission;
     _repDepreciation   = repDepreciation;
 }
コード例 #35
0
        private static void ConfigureOAuth(IAppBuilder app, IUserAuthentication userAppService, INotifiable <UserAuthenticated> userAuthenticateNotification)
        {
            var OAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp           = true,
                TokenEndpointPath           = new PathString("/api/security/token"),
                AccessTokenExpireTimeSpan   = TimeSpan.FromMinutes(1),
                ApplicationCanDisplayErrors = true,
                Provider = new SimpleAuthorizationServerProvider(userAppService, userAuthenticateNotification)
            };

            // Token Generation
            app.UseOAuthAuthorizationServer(OAuthServerOptions);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
        }
コード例 #36
0
ファイル: AccessController.cs プロジェクト: ashmind/gallery
 public AccessController(
     IOpenIdAjaxRelyingParty openId,
     IUserAuthentication authentication,
     IRepository<IUserGroup> userGroupRepository,
     IAuthorizationService authorization,
     IAlbumFacade gallery
     )
     : base(authentication)
 {
     this.openId = openId;
     this.authentication = authentication;
     this.userGroupRepository = userGroupRepository;
     this.authorization = authorization;
     this.gallery = gallery;
 }
コード例 #37
0
 public RssSubscriptionService(
     IRssChannelsSubscriptionsRepository rssSubscriptionsRepository,
     IRssEntriesToReadRepository rssToReadRepository,
     IRssEventRepository rssEventsRepository,
     IRssChannelsRepository rssChannelsRepository,
     ISubscriptionHandlerFactory subscriptionHandlerFactory,
     IUserAuthentication authentication)
 {
     this.rssSubscriptionsRepository = rssSubscriptionsRepository;
     this.rssToReadRepository = rssToReadRepository;
     this.rssEventsRepository = rssEventsRepository;
     this.rssChannelsRepository = rssChannelsRepository;
     this.subscriptionHandlerFactory = subscriptionHandlerFactory;
     this.authentication = authentication;
 }
コード例 #38
0
 public ApplicationLoginService(
     IUserAuthentication authentication,
     IUserRepository userRepository,
     ISocialLoginRepository socialLoginRepository,
     IUserRoleRepository repositoryUserRoles,
     IMapper mapper,
     IApplicationSettingsRepository applicationSettingsRepository)
 {
     this.authentication = authentication;
     this.userRepository = userRepository;
     this.socialLoginRepository = socialLoginRepository;
     this.repositoryUserRoles = repositoryUserRoles;
     this.mapper = mapper;
     this.applicationSettingsRepository = applicationSettingsRepository;
 }
コード例 #39
0
 public ApplicationLoginService(
     IUserAuthentication authentication,
     IUserRepository userRepository,
     ISocialLoginRepository socialLoginRepository,
     ISessionProvider sessionProvider,
     IUserRoleRepository repositoryUserRoles,
     IMapper mapper)
 {
     this.authentication        = authentication;
     this.userRepository        = userRepository;
     this.socialLoginRepository = socialLoginRepository;
     this.sessionProvider       = sessionProvider;
     this.repositoryUserRoles   = repositoryUserRoles;
     this.mapper = mapper;
 }
コード例 #40
0
 public UserController(
     IUserManagement UserManagement,
     IMiddleManagement MiddleManagment,
     IUserSession UserSession,
     IUserAuthentication UserAuthentication,
     IEnumerable<IUserAuthenticator> UserAuthenticators,
     IFormsAuthentication FormsAuthentication,
     IStringHash StringHash)
     : base(MiddleManagment, UserSession, FormsAuthentication)
 {
     userManagement = UserManagement;
     userAuthentication = UserAuthentication;
     userAuthenticators = UserAuthenticators;
     formsAuthentication = FormsAuthentication;
     stringHash = StringHash;
 }
コード例 #41
0
ファイル: UserManagement.cs プロジェクト: hoangduit/openpetra
        public static bool GetAuthenticationFunctionality(out bool ACanCreateUser, out bool ACanChangePassword, out bool ACanChangePermissions)
        {
            ACanCreateUser        = true;
            ACanChangePassword    = true;
            ACanChangePermissions = true;

            string UserAuthenticationMethod = TAppSettingsManager.GetValue("UserAuthenticationMethod", "OpenPetraDBSUser", false);

            if (UserAuthenticationMethod != "OpenPetraDBSUser")
            {
                IUserAuthentication auth = TUserManagerWebConnector.LoadAuthAssembly(UserAuthenticationMethod);

                auth.GetAuthenticationFunctionality(out ACanCreateUser, out ACanChangePassword, out ACanChangePermissions);
            }

            return(true);
        }
コード例 #42
0
        public static IUserAuthentication LoadAuthAssembly(string AUserAuthenticationMethod)
        {
            if (FUserAuthenticationClass == null)
            {
                // namespace of the class TUserAuthentication, eg. Plugin.AuthenticationPhpBB
                // the dll has to be in the normal application directory
                string Namespace   = AUserAuthenticationMethod;
                string NameOfDll   = TAppSettingsManager.ApplicationDirectory + Path.DirectorySeparatorChar + Namespace + ".dll";
                string NameOfClass = Namespace + ".TUserAuthentication";

                // dynamic loading of dll
                System.Reflection.Assembly assemblyToUse = System.Reflection.Assembly.LoadFrom(NameOfDll);
                System.Type CustomClass = assemblyToUse.GetType(NameOfClass);

                FUserAuthenticationClass = (IUserAuthentication)Activator.CreateInstance(CustomClass);
            }

            return(FUserAuthenticationClass);
        }
コード例 #43
0
        public static void SimulatePasswordAuthenticationForNonExistingUser()
        {
            string UserAuthenticationMethod = TAppSettingsManager.GetValue("UserAuthenticationMethod", "OpenPetraDBSUser", false);

            if (UserAuthenticationMethod == "OpenPetraDBSUser")
            {
                TUserManagerWebConnector.CreateHashOfPassword("wrongPassword",
                                                              Convert.ToBase64String(TPasswordHelper.CurrentPasswordScheme.GetNewPasswordSalt()),
                                                              TPasswordHelper.CurrentPasswordSchemeNumber);
            }
            else
            {
                IUserAuthentication auth = TUserManagerWebConnector.LoadAuthAssembly(UserAuthenticationMethod);

                string ErrorMessage;

                auth.AuthenticateUser("wrongUser", "wrongPassword", out ErrorMessage);
            }
        }
コード例 #44
0
ファイル: UserManager.cs プロジェクト: Davincier/openpetra
        public static IUserAuthentication LoadAuthAssembly(string AUserAuthenticationMethod)
        {
            if (FUserAuthenticationClass == null)
            {
                // namespace of the class TUserAuthentication, eg. Plugin.AuthenticationPhpBB
                // the dll has to be in the normal application directory
                string Namespace = AUserAuthenticationMethod;
                string NameOfDll = TAppSettingsManager.ApplicationDirectory + Path.DirectorySeparatorChar + Namespace + ".dll";
                string NameOfClass = Namespace + ".TUserAuthentication";

                // dynamic loading of dll
                System.Reflection.Assembly assemblyToUse = System.Reflection.Assembly.LoadFrom(NameOfDll);
                System.Type CustomClass = assemblyToUse.GetType(NameOfClass);

                FUserAuthenticationClass = (IUserAuthentication)Activator.CreateInstance(CustomClass);
            }

            return FUserAuthenticationClass;
        }
コード例 #45
0
ファイル: UserManagement.cs プロジェクト: hoangduit/openpetra
        public static bool SetUserPassword(string AUsername, string APassword, bool APasswordNeedsChanged, bool AUnretireIfRetired)
        {
            string UserAuthenticationMethod = TAppSettingsManager.GetValue("UserAuthenticationMethod", "OpenPetraDBSUser", false);

            if (UserAuthenticationMethod == "OpenPetraDBSUser")
            {
                TDBTransaction  SubmitChangesTransaction = null;
                bool            SubmissionResult         = false;
                TPetraPrincipal tempPrincipal;

                DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref SubmitChangesTransaction,
                                                           ref SubmissionResult,
                                                           delegate
                {
                    SUserRow UserDR      = TUserManagerWebConnector.LoadUser(AUsername.ToUpper(), out tempPrincipal);
                    SUserTable UserTable = (SUserTable)UserDR.Table;

                    Random r            = new Random();
                    UserDR.PasswordSalt = r.Next(1000000000).ToString();
                    UserDR.PasswordHash = TUserManagerWebConnector.CreateHashOfPassword(String.Concat(APassword,
                                                                                                      UserDR.PasswordSalt), "SHA1");
                    UserDR.PasswordNeedsChange = APasswordNeedsChanged;

                    // unretire the user if it has been previously retired
                    if (AUnretireIfRetired)
                    {
                        UserDR.Retired = false;
                    }

                    SUserAccess.SubmitChanges(UserTable, SubmitChangesTransaction);

                    SubmissionResult = true;
                });

                return(true);
            }
            else
            {
                IUserAuthentication auth = TUserManagerWebConnector.LoadAuthAssembly(UserAuthenticationMethod);

                return(auth.SetPassword(AUsername, APassword));
            }
        }
コード例 #46
0
ファイル: UserService.cs プロジェクト: williamnwz/app-secrect
 public UserService(
     IDtoMapper <User, CreateUser> regiserUserMapper,
     IDtoMapper <User, LoginDto> userDtoToUserMapper,
     IDtoMapper <LoginResponse, User> userToLoginResponseMapper,
     ISaveUser createUser,
     IUserAuthentication userAuthentication,
     IMakeFriendship makeFriendship,
     INameGenerate nameGenerate,
     IUserRepository userRepository,
     IUnityOfWork unityOfWork)
 {
     this.regiserUserMapper         = regiserUserMapper;
     this.createUser                = createUser;
     this.userToLoginResponseMapper = userToLoginResponseMapper;
     this.userDtoToUserMapper       = userDtoToUserMapper;
     this.userAuthentication        = userAuthentication;
     this.makeFriendship            = makeFriendship;
     this.nameGenerate              = nameGenerate;
     this.unityOfWork               = unityOfWork;
     this.userRepository            = userRepository;
 }
コード例 #47
0
 public RssChannelsService(
     IRssChannelsRepository channelsRepository,
     ISessionProvider sessionProvider,
     IRssChannelsSubscriptionsRepository channelsSubscriptionRepository,
     IRssEntriesToReadRepository rssEntriesToReadRepository,
     IUserAuthentication authentication,
     IRssChannelsSubscriptionsRepository rssSubscriptionRepository,
     ISessionProvider session,
     IMapper mapping,
     IEventRssChannelCreatedRepository eventRssChannelCreatedRepository)
 {
     this.channelsRepository             = channelsRepository;
     this.sessionProvider                = sessionProvider;
     this.channelsSubscriptionRepository = channelsSubscriptionRepository;
     this.rssEntriesToReadRepository     = rssEntriesToReadRepository;
     this.authentication            = authentication;
     this.rssSubscriptionRepository = rssSubscriptionRepository;
     this.session = session;
     this.mapping = mapping;
     this.eventRssChannelCreatedRepository = eventRssChannelCreatedRepository;
 }
コード例 #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoginController"/> class.
 /// </summary>
 public LoginController(IUserAuthentication userAuthentication, IUserSession <Domain.Model.User> userSession)
 {
     _userAuthentication = userAuthentication;
     _userSession        = userSession;
 }
コード例 #49
0
ファイル: AuthController.cs プロジェクト: praburamkr/MARSPOC
 public AuthController(IUserAuthentication auth, ILogHandler logHandler, IExceptionHandler exceptionHandler)
 {
     authentication        = auth;
     this.logHandler       = logHandler;
     this.exceptionHandler = exceptionHandler;
 }
コード例 #50
0
ファイル: UserManagement.cs プロジェクト: hoangduit/openpetra
        public static bool CreateUser(string AUsername, string APassword, string AFirstName, string AFamilyName, string AModulePermissions)
        {
            TDBTransaction ReadTransaction          = null;
            TDBTransaction SubmitChangesTransaction = null;
            bool           UserExists   = false;
            bool           SubmissionOK = false;

            // TODO: check permissions. is the current user allowed to create other users?
            SUserTable userTable = new SUserTable();
            SUserRow   newUser   = userTable.NewRowTyped();

            newUser.UserId    = AUsername;
            newUser.FirstName = AFirstName;
            newUser.LastName  = AFamilyName;

            if (AUsername.Contains("@"))
            {
                newUser.EmailAddress = AUsername;
                newUser.UserId       = AUsername.Substring(0, AUsername.IndexOf("@")).
                                       Replace(".", string.Empty).
                                       Replace("_", string.Empty).ToUpper();
            }

            // Check whether the user that we are asked to create already exists
            DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref ReadTransaction,
                                                           delegate
            {
                if (SUserAccess.Exists(newUser.UserId, ReadTransaction))
                {
                    TLogging.Log("Cannot create new user as a user with User Name '" + newUser.UserId + "' already exists!");
                    UserExists = true;
                }
            });

            if (UserExists)
            {
                return(false);
            }

            userTable.Rows.Add(newUser);

            string UserAuthenticationMethod = TAppSettingsManager.GetValue("UserAuthenticationMethod", "OpenPetraDBSUser", false);

            if (UserAuthenticationMethod == "OpenPetraDBSUser")
            {
                if (APassword.Length > 0)
                {
                    newUser.PasswordSalt        = PasswordHelper.GetNewPasswordSalt();
                    newUser.PasswordHash        = PasswordHelper.GetPasswordHash(APassword, newUser.PasswordSalt);
                    newUser.PasswordNeedsChange = true;
                }
            }
            else
            {
                try
                {
                    IUserAuthentication auth = TUserManagerWebConnector.LoadAuthAssembly(UserAuthenticationMethod);

                    if (!auth.CreateUser(AUsername, APassword, AFirstName, AFamilyName))
                    {
                        newUser = null;
                    }
                }
                catch (Exception e)
                {
                    TLogging.Log("Problem loading user authentication method " + UserAuthenticationMethod + ": " + e.ToString());
                    return(false);
                }
            }

            if (newUser != null)
            {
                DBAccess.GDBAccessObj.BeginAutoTransaction(IsolationLevel.Serializable, ref SubmitChangesTransaction, ref SubmissionOK,
                                                           delegate
                {
                    SUserAccess.SubmitChanges(userTable, SubmitChangesTransaction);

                    List <string> modules = new List <string>();

                    if (AModulePermissions == DEMOMODULEPERMISSIONS)
                    {
                        modules.Add("PTNRUSER");
                        modules.Add("FINANCE-1");

                        ALedgerTable theLedgers = ALedgerAccess.LoadAll(SubmitChangesTransaction);

                        foreach (ALedgerRow ledger in theLedgers.Rows)
                        {
                            modules.Add("LEDGER" + ledger.LedgerNumber.ToString("0000"));
                        }
                    }
                    else
                    {
                        string[] modulePermissions = AModulePermissions.Split(new char[] { ',' });

                        foreach (string s in modulePermissions)
                        {
                            if (s.Trim().Length > 0)
                            {
                                modules.Add(s.Trim());
                            }
                        }
                    }

                    SUserModuleAccessPermissionTable moduleAccessPermissionTable = new SUserModuleAccessPermissionTable();

                    foreach (string module in modules)
                    {
                        SUserModuleAccessPermissionRow moduleAccessPermissionRow = moduleAccessPermissionTable.NewRowTyped();
                        moduleAccessPermissionRow.UserId    = newUser.UserId;
                        moduleAccessPermissionRow.ModuleId  = module;
                        moduleAccessPermissionRow.CanAccess = true;
                        moduleAccessPermissionTable.Rows.Add(moduleAccessPermissionRow);
                    }

                    SUserModuleAccessPermissionAccess.SubmitChanges(moduleAccessPermissionTable, SubmitChangesTransaction);

                    // TODO: table permissions should be set by the module list
                    // TODO: add p_data_label... tables here so user can generally have access
                    string[] tables = new string[] {
                        "p_bank", "p_church", "p_family", "p_location",
                        "p_organisation", "p_partner", "p_partner_location",
                        "p_partner_type", "p_person", "p_unit", "p_venue",
                        "p_data_label", "p_data_label_lookup", "p_data_label_lookup_category", "p_data_label_use", "p_data_label_value_partner",
                    };

                    SUserTableAccessPermissionTable tableAccessPermissionTable = new SUserTableAccessPermissionTable();

                    foreach (string table in tables)
                    {
                        SUserTableAccessPermissionRow tableAccessPermissionRow = tableAccessPermissionTable.NewRowTyped();
                        tableAccessPermissionRow.UserId    = newUser.UserId;
                        tableAccessPermissionRow.TableName = table;
                        tableAccessPermissionTable.Rows.Add(tableAccessPermissionRow);
                    }

                    SUserTableAccessPermissionAccess.SubmitChanges(tableAccessPermissionTable, SubmitChangesTransaction);

                    SubmissionOK = true;
                });

                return(true);
            }

            return(false);
        }
コード例 #51
0
ファイル: UserManagement.cs プロジェクト: hoangduit/openpetra
        public static bool SetUserPassword(string AUsername,
                                           string APassword,
                                           string AOldPassword,
                                           bool APasswordNeedsChanged,
                                           out TVerificationResultCollection AVerification)
        {
            TDBTransaction      Transaction;
            string              UserAuthenticationMethod = TAppSettingsManager.GetValue("UserAuthenticationMethod", "OpenPetraDBSUser", false);
            TVerificationResult VerificationResult;

            AVerification = new TVerificationResultCollection();

            if (!TSharedSysManValidation.CheckPasswordQuality(APassword, out VerificationResult))
            {
                return(false);
            }

            if (APasswordNeedsChanged && APassword == AOldPassword)
            {
                AVerification = new TVerificationResultCollection();
                AVerification.Add(new TVerificationResult("\nPassword check.",
                                                          Catalog.GetString(
                                                              "Password not changed as the old password was reused. Please use a new password."),
                                                          TResultSeverity.Resv_Critical));
                return(false);
            }

            if (UserAuthenticationMethod == "OpenPetraDBSUser")
            {
                TPetraPrincipal tempPrincipal;
                SUserRow        UserDR = TUserManagerWebConnector.LoadUser(AUsername.ToUpper(), out tempPrincipal);

                if (TUserManagerWebConnector.CreateHashOfPassword(String.Concat(AOldPassword,
                                                                                UserDR.PasswordSalt)) != UserDR.PasswordHash)
                {
                    AVerification = new TVerificationResultCollection();
                    AVerification.Add(new TVerificationResult("\nPassword quality check.",
                                                              String.Format(
                                                                  Catalog.GetString(
                                                                      "Old password entered incorrectly. Password not changed.")),
                                                              TResultSeverity.Resv_Critical));
                    return(false);
                }

                SUserTable UserTable = (SUserTable)UserDR.Table;

                UserDR.PasswordHash = TUserManagerWebConnector.CreateHashOfPassword(String.Concat(APassword,
                                                                                                  UserDR.PasswordSalt));
                UserDR.PasswordNeedsChange = false;

                Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable);

                try
                {
                    SUserAccess.SubmitChanges(UserTable, Transaction);

                    DBAccess.GDBAccessObj.CommitTransaction();
                }
                catch (Exception Exc)
                {
                    TLogging.Log("An Exception occured during the setting of the User Password:" + Environment.NewLine + Exc.ToString());

                    DBAccess.GDBAccessObj.RollbackTransaction();

                    throw;
                }

                return(true);
            }
            else
            {
                IUserAuthentication auth = TUserManagerWebConnector.LoadAuthAssembly(UserAuthenticationMethod);

                return(auth.SetPassword(AUsername, APassword, AOldPassword));
            }
        }
コード例 #52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserAuthenticationService"/> class.
 /// </summary>
 /// <param name="userAuthentication">The user authentication.</param>
 /// <param name="emailService">The email service.</param>
 /// <param name="appInfoService">The app info service.</param>
 public UserAuthenticationService(IUserAuthentication userAuthentication, IEmailService emailService, IAppInfoService appInfoService)
 {
     _userAuthentication = userAuthentication;
     _emailService       = emailService;
     _appInfoService     = appInfoService;
 }
コード例 #53
0
ファイル: RESTService.cs プロジェクト: ramz/sones
 public PasswordValidator(IUserAuthentication dbAuthentcator, String Username, String Password)
 {
     _dbauth = dbAuthentcator;
     _Username = Username;
     _Password = Password;
 }
コード例 #54
0
 /// <summary>
 /// 构造函数。
 /// </summary>
 public AuthenticationProvider()
 {
     this.authentication = new DataSyncFactory();
 }
コード例 #55
0
 public SimpleAuthorizationServerProvider(IUserAuthentication userAuthentication, INotifiable <UserAuthenticated> userAuthenticateNotification)
 {
     _userAuthentication           = userAuthentication;
     _userAuthenticateNotification = userAuthenticateNotification;
 }
コード例 #56
0
 public RssItemActionService(IRssActionRepository rssItemActionRepository,
     IUserAuthentication authentication)
 {
     this.rssItemActionRepository = rssItemActionRepository;
     this.authentication = authentication;
 }
コード例 #57
0
 public AccountService(IUserRepository userRepository, IMapper mapper, IUserAuthentication authentication)
 {
     this.userRepository = userRepository;
     this.mapper = mapper;
     this.authentication = authentication;
 }
コード例 #58
0
 protected BaseController(IUserAuthentication authentication, ILoginService loginService, ISessionProvider sessionProvider)
 {
     this.authentication = authentication;
     this.loginService = loginService;
     this.sessionProvider = sessionProvider;
 }
コード例 #59
0
 protected BaseController(IUserAuthentication authentication, ILoginService loginService, ISessionProvider sessionProvider)
 {
     this.authentication  = authentication;
     this.loginService    = loginService;
     this.sessionProvider = sessionProvider;
 }
コード例 #60
0
 public AlbumItemController(IAlbumFacade gallery, IUserAuthentication authentication)
     : base(authentication)
 {
     this.gallery = gallery;
 }