Package org.libreplan.web.users.services

Examples of org.libreplan.web.users.services.CustomUser


    }

    private static final Log LOG = LogFactory.getLog(UserUtil.class);

    public static User getUserFromSession() {
        CustomUser loggedUser = SecurityUtils.getLoggedUser();
        if (loggedUser != null) {
            String username = loggedUser.getUsername();
            try {
                return Registry.getUserDAO().findByLoginName(username);
            } catch (InstanceNotFoundException e) {
                LOG.info("User " + username + " not found in database.");
                return null;
View Full Code Here


        Scenario scenario = scenarioAssociatedToLoggedUser();
        return reload(scenario);
    }

    private Scenario scenarioAssociatedToLoggedUser() {
        CustomUser loggedUser = SecurityUtils.getLoggedUser();
        if (loggedUser == null) {
            return scenariosBootstrap.getMain();
        }
        return loggedUser.getScenario();
    }
View Full Code Here

        return result;
    }

    private Scenario givenUserAuthenticatedWith(Scenario customScenario) {
        SecurityContext context = SecurityContextHolder.getContext();
        CustomUser user = createUserWithScenario(customScenario);
        Authentication authentication = stubAuthenticationWithPrincipal(user);
        context.setAuthentication(authentication);
        return customScenario;
    }
View Full Code Here

        return customScenario;
    }


    private CustomUser createUserWithScenario(Scenario customScenario) {
        CustomUser result = createNiceMock(CustomUser.class);
        expect(result.getScenario()).andReturn(customScenario).anyTimes();
        replay(result);
        return result;
    }
View Full Code Here

        return VersionInformation.isNewVersionAvailable(templateModel
                .isAllowToGatherUsageStatsEnabled());
    }

    public String getUsername() {
        CustomUser user = SecurityUtils.getLoggedUser();
        if (user == null) {
            return "";
        }
        return user.getUsername();
    }
View Full Code Here

        return Registry.getTransactionService().runOnReadOnlyTransaction(
                new IOnTransaction<Boolean>() {
                    @Override
                    public Boolean execute() {
                        try {
                            CustomUser customUser = getLoggedUser();
                            if (customUser == null) {
                                return false;
                            }
                            String username = customUser.getUsername();
                            return Registry
                                    .getOrderAuthorizationDAO()
                                    .userOrItsProfilesHaveAnyAuthorization(
                                            Registry.getUserDAO()
                                                    .findByLoginName(
View Full Code Here

            return true;
        }

        User user;
        try {
            CustomUser loggedUser = getLoggedUser();
            if (loggedUser == null) {
                return false;
            }
            user = Registry.getUserDAO().findByLoginName(
                    loggedUser.getUsername());
        } catch (InstanceNotFoundException e) {
            Log.warn("Logged user not found in database", e);
            return false;
        }
View Full Code Here

    }

    private void associateToUser(Scenario scenario, User user) {
        user.setLastConnectedScenario(scenario);
        userDAO.save(user);
        CustomUser customUser = SecurityUtils.getLoggedUser();
        assert customUser != null : "user must be logged for this method to be called";

        customUser.setScenario(scenario);
    }
View Full Code Here

TOP

Related Classes of org.libreplan.web.users.services.CustomUser

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.