Examples of UserRepository


Examples of com.nurkiewicz.jdbcrepository.repositories.UserRepository

  }

  @Bean
  @Override
  public UserRepository userRepository() {
    return new UserRepository("users");
  }
View Full Code Here

Examples of com.sun.messaging.jmq.auth.api.server.model.UserRepository

        if (cn == null) {
            throw new LoginException(
            Globals.getBrokerResources().getKString(
            BrokerResources.X_USER_REPOSITORY_CLASS_NOT_DEFINED, rep, getType()));
        }
        UserRepository repository =  (UserRepository)Class.forName(cn).newInstance();
        repository.open(getType(), authProps, cacheData);
        subject = repository.findMatch(username, credential, nonce, getMatchType());
        cacheData = repository.getCacheData();
        repository.close();
        repository = null;
        if (subject == null) {
            FailedLoginException ex = new FailedLoginException(
                Globals.getBrokerResources().getKString(
                    BrokerResources.X_FORBIDDEN, username));
View Full Code Here

Examples of io.lumify.core.model.user.UserRepository

    @Override
    public void valueUnbound(HttpSessionBindingEvent event) {
        UserStatus status = UserStatus.OFFLINE;
        LOGGER.info("setting userId %s status to %s", userId, status);
        try {
            UserRepository userRepository = InjectHelper.getInstance(UserRepository.class);
            User user = userRepository.setStatus(userId, status);
            WorkQueueRepository workQueueRepository = InjectHelper.getInstance(WorkQueueRepository.class);
            workQueueRepository.pushUserStatusChange(user, status);
        } catch (Exception ex) {
            LOGGER.error("exception while setting userId %s status to %s", userId, status, ex);
        }
View Full Code Here

Examples of org.b3log.solo.repository.UserRepository

     *
     * @throws Exception exception
     */
    @Test
    public void test() throws Exception {
        final UserRepository userRepository = getUserRepository();

        final JSONObject another = new JSONObject();
        another.put(User.USER_NAME, "test1");
        another.put(User.USER_EMAIL, "test1@gmail.com");
        another.put(User.USER_PASSWORD, "pass1");
        another.put(User.USER_ROLE, Role.DEFAULT_ROLE);
        another.put(UserExt.USER_ARTICLE_COUNT, 0);
        another.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0);

        Transaction transaction = userRepository.beginTransaction();
        userRepository.add(another);
        transaction.commit();

        Assert.assertNull(userRepository.getAdmin());

        JSONObject admin = new JSONObject();
        admin.put(User.USER_NAME, "test");
        admin.put(User.USER_EMAIL, "test@gmail.com");
        admin.put(User.USER_PASSWORD, "pass");
        admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
        admin.put(UserExt.USER_ARTICLE_COUNT, 0);
        admin.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0);

        transaction = userRepository.beginTransaction();
        userRepository.add(admin);
        transaction.commit();

        Assert.assertTrue(userRepository.isAdminEmail("test@gmail.com"));
        Assert.assertFalse(userRepository.isAdminEmail("notFound@gmail.com"));

        admin = userRepository.getAdmin();

        Assert.assertNotNull(admin);
        Assert.assertEquals("test", admin.optString(User.USER_NAME));

        final JSONObject result =
                userRepository.get(new Query().addFilter(User.USER_NAME,
                                                         FilterOperator.EQUAL,
                                                         "test1"));

        final JSONArray users = result.getJSONArray(Keys.RESULTS);
        Assert.assertEquals(users.length(), 1);
        Assert.assertEquals(users.getJSONObject(0).getString(User.USER_EMAIL),
                            "test1@gmail.com");

        final JSONObject notFound =
                userRepository.getByEmail("not.found@gmail.com");
        Assert.assertNull(notFound);

        final JSONObject found = userRepository.getByEmail("test1@gmail.com");
        Assert.assertNotNull(found);
        Assert.assertEquals(found.getString(User.USER_PASSWORD), "pass1");
    }
View Full Code Here

Examples of org.b3log.solo.repository.UserRepository

     *
     * @throws Exception exception
     */
    @Test
    public void test() throws Exception {
        final UserRepository userRepository = getUserRepository();

        final JSONObject another = new JSONObject();
        another.put(User.USER_NAME, "test1");
        another.put(User.USER_EMAIL, "test1@gmail.com");
        another.put(User.USER_PASSWORD, "pass1");
        another.put(User.USER_URL, "http://b3log.org");
        another.put(User.USER_ROLE, Role.DEFAULT_ROLE);
        another.put(UserExt.USER_ARTICLE_COUNT, 0);
        another.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0);

        Transaction transaction = userRepository.beginTransaction();
        userRepository.add(another);
        transaction.commit();

        Assert.assertNull(userRepository.getAdmin());

        JSONObject admin = new JSONObject();
        admin.put(User.USER_NAME, "test");
        admin.put(User.USER_EMAIL, "test@gmail.com");
        admin.put(User.USER_PASSWORD, "pass");
        admin.put(User.USER_URL, "http://b3log.org");
        admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
        admin.put(UserExt.USER_ARTICLE_COUNT, 0);
        admin.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0);

        transaction = userRepository.beginTransaction();
        userRepository.add(admin);
        transaction.commit();

        Assert.assertTrue(userRepository.isAdminEmail("test@gmail.com"));
        Assert.assertFalse(userRepository.isAdminEmail("notFound@gmail.com"));

        admin = userRepository.getAdmin();

        Assert.assertNotNull(admin);
        Assert.assertEquals("test", admin.optString(User.USER_NAME));

        final JSONObject result = userRepository.get(new Query().setFilter(
                new PropertyFilter(User.USER_NAME, FilterOperator.EQUAL, "test1")));

        final JSONArray users = result.getJSONArray(Keys.RESULTS);
        Assert.assertEquals(users.length(), 1);
        Assert.assertEquals(users.getJSONObject(0).getString(User.USER_EMAIL), "test1@gmail.com");

        final JSONObject notFound = userRepository.getByEmail("not.found@gmail.com");
        Assert.assertNull(notFound);

        final JSONObject found = userRepository.getByEmail("test1@gmail.com");
        Assert.assertNotNull(found);
        Assert.assertEquals(found.getString(User.USER_PASSWORD), "pass1");
    }
View Full Code Here

Examples of org.fao.geonet.repository.UserRepository

    if (!us.isAuthenticated())
      return new ArrayList<Element>();

    int userId = Integer.parseInt(us.getUserId());

        final UserRepository userRepository = context.getBean(UserRepository.class);
        if (us.getProfile() == Profile.Administrator) {
      @SuppressWarnings("unchecked")
            List<Element> allUsers = userRepository.findAllAsXml().getChildren();
            return allUsers;
    }

    if (us.getProfile() != Profile.UserAdmin) {
            @SuppressWarnings("unchecked")
            List<Element> identifiedUsers = userRepository.findAllAsXml(UserSpecs.hasUserId(userId)).getChildren();;
            return identifiedUsers;
        }

    //--- we have a user admin

    Set<Integer> hsMyGroups = getUserGroups(context, userId);

        Set<String> profileSet = us.getProfile().getAllNames();

    //--- retrieve all users

    Element elUsers = userRepository.findAllAsXml(null, SortUtils.createSort(User_.name));

    //--- now filter them

    ArrayList<Element> alToRemove = new ArrayList<Element>();
View Full Code Here

Examples of org.fao.geonet.repository.UserRepository

     * @param changeMessage Message supplied by the user that set the status
     */
    protected void informContentReviewers(Set<Integer> metadata, String changeDate, String changeMessage) throws Exception {

        // --- get content reviewers (sorted on content reviewer userid)
        UserRepository userRepository = context.getBean(UserRepository.class);
        List<Pair<Integer, User>> results = userRepository.findAllByGroupOwnerNameAndProfile(metadata,
                Profile.Reviewer, SortUtils.createSort(User_.name));

        List<User> users = Lists.transform(results, new Function<Pair<Integer, User>, User>() {
            @Nullable
            @Override
View Full Code Here

Examples of org.fao.geonet.repository.UserRepository

                translatedStatusName, replyToDescr, replyTo, changeDate);
        String mdChanged = buildMetadataChangedMessage(metadataIds);
       
        Iterable<Metadata> metadata = this.context.getBean(MetadataRepository.class).findAll(metadataIds);
        List<User> owners = new ArrayList<User>();
        UserRepository userRepo = this.context.getBean(UserRepository.class);

        for (Metadata md : metadata) {
            int ownerId = md.getSourceInfo().getOwner();
            owners.add(userRepo.findOne(ownerId));
        }

        processList(owners, subject, status, changeDate, changeMessage, mdChanged);

    }
View Full Code Here

Examples of org.fao.geonet.repository.UserRepository

   * @throws SQLException if an error occurred during a database access
   * @throws UserNotFoundEx  if the id does not reference a user
   */
  public static User updatePasswordWithNew(boolean matchOldPassword, String oldPassword,
      String newPassword, Integer iUserId, ApplicationContext appContext) throws SQLException, UserNotFoundEx {
      UserRepository repo = appContext.getBean(UserRepository.class);
        User user = repo.findOne(iUserId);
        if (user == null) {
            throw new UserNotFoundEx(""+iUserId);
        }

        PasswordEncoder encoder = encoder(appContext);
View Full Code Here

Examples of org.fao.geonet.repository.UserRepository

    // TODO: I am not sure this is the expected behaviour: allowing people to create
    // even temporary account as administrator, just noticing the admin catalogue
    // might be a dangerous behaviour.

    final UserRepository userRepository = svcCtx.getBean(UserRepository.class);
    User newUsr = userRepository.findOneByEmail("root@localhost");
       
    assertTrue (newUsr.getProfile() == Profile.Administrator);
   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.