Package io.conducive.shared.model

Examples of io.conducive.shared.model.User


        addProvider(new BasicAuthProvider(injector.getInstance(SimpleAuthenticator.class), "authrealm"));
    }

    @Test
    public void testCreate() throws Exception {
        final User user = new User();
        user.setUsername("reuben");
        String hash = sha256().hashBytes("foo".getBytes("UTF-8")).toString().substring(0, 64);
        String salt = "banana";
        user.setHash(hash);
        user.setSalt(salt);
        client().resource("/user").type(MediaType.APPLICATION_JSON_TYPE).put(user);

        verify(dao).createUser(user);

        // test get
View Full Code Here


        for (String username : new String[]{"john", "peter", "fred", "margaret", "paul"}) {
            final String password = username.substring(0, 2) + username.substring(0, 2);
            final String salt = "this is a salt";

            User user1 = new User();
            user1.setUsername(username);
            user1.setHash(password);
            user1.setSalt(salt);
            dao.createUser(user1);
            final User user2 = dao.getUser(username, password, salt);
            assertNull(dao.getUser(username, "foobah", salt));

            assertEquals(user2.getUsername(), username);
            assertNotSame(user2.getHash(), password);
        }
    }
View Full Code Here

    @Inject
    UserDAO dao;

    @Override
    public Optional<User> authenticate(BasicCredentials credentials) {
        final User user = dao.getUser(credentials.getUsername(), credentials.getPassword().substring(0, 64), credentials.getPassword().substring(64));
        if (user != null) {
            return Optional.of(user);
        }
        return Optional.absent();
    }
View Full Code Here

        initWidget(loginView);
    }

    @Subscribe
    void tryLogin(ClickLoginEvent event) {
        final User user = new User(event.getUsername());
        user.setHash(event.getPassword());
        user.setSalt(event.getSalt());
        api.login(user, new HttpCallback<Boolean>(eventBus, Boolean.class) {
            @Override
            public void onSuccess(Boolean result) {
                if (result) {
                    eventBus.post(new UserAuthorizedEvent(user, false));
View Full Code Here

        });
    }

    @Subscribe
    void tryRegister(ClickRegisterEvent event) {
        final User user = new User(event.getUsername());
        user.setHash(event.getPassword());
        user.setSalt(event.getSalt());
        api.register(user, new HttpCallback<Boolean>(eventBus, Boolean.class) {
            @Override
            public void onSuccess(Boolean result) {
                if (result) {
                    eventBus.post(new UserAuthorizedEvent(user, true));
View Full Code Here

    @Override
    public User getUser(final String username, final String password, final String salt) {
        checkNotNull(username, "Username should not be null");
        checkNotNull(password, "Password should not be null");

        final User user = users().get(username);
        if (user != null) {
            if (stretch(password, salt, EXP).equals(user.getHash())) {
                // don't surface the hash
                return new User(username);
            }
        }
        return null;
    }
View Full Code Here

        }

        // hash from client is already stretched. stretch some more. distance from what is stored vs password is
        // 2^(LoginView.EXP + UserDAOImpl.EXP), i.e. 2^29
        logger.info("Stretching");
        User toStore = new User(user.getUsername(), stretch(user.getHash(), user.getSalt(), EXP));
        toStore.setSalt(user.getSalt());
        logger.info("Done stretching");
        users().put(user.getUsername(), toStore);
        // save to disk
        commit();
    }
View Full Code Here

TOP

Related Classes of io.conducive.shared.model.User

Copyright © 2018 www.massapicom. 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.