Examples of PersonPrincipal


Examples of org.nxplanner.security.PersonPrincipal

    }

    private int getCurrentUserId() throws JspException {
        if (SecurityHelper.isUserAuthenticated((HttpServletRequest)pageContext.getRequest())) {
            try {
                PersonPrincipal me = (PersonPrincipal)(SecurityHelper.getUserPrincipal((HttpServletRequest)pageContext.getRequest()));
                return me.getPerson().getId();
            } catch (AuthenticationException e) {
                throw new JspException(e);
            }
        }
        return 0;
View Full Code Here

Examples of org.nxplanner.security.PersonPrincipal

            throws AuthenticationException {
        Person person = getPerson(userId);
        if (person == null) {
            throw new AuthenticationException("user " + userId + " not found");
        }
        subject.getPrincipals().add(new PersonPrincipal(person));

    }
View Full Code Here

Examples of org.nxplanner.security.PersonPrincipal

            try {
                log.log(loggingPriority, "looking for user: " + userId);
                Person person = getPerson(session, userId);
                if (person != null) {
                    HashSet principals = new HashSet();
                    principals.add(new PersonPrincipal(person));
                    return new Subject(false, principals, new HashSet(), new HashSet());
                }
                throw new AuthenticationException("no such user in xplanner");
            } catch (AuthenticationException ex) {
                throw ex;
View Full Code Here

Examples of org.nxplanner.security.PersonPrincipal

                log.log(loggingPriority, "attempting to authenticate: " + userId);
                Person person = getPerson(session, userId);
                if (person != null) {
                    if (isPasswordMatched(person, password)) {
                        HashSet principals = new HashSet();
                        principals.add(new PersonPrincipal(person));
                        return new Subject(false, principals, new HashSet(), new HashSet());
                    }
                }
                throw new AuthenticationException("Invalid login.");
            } catch (AuthenticationException ex) {
View Full Code Here

Examples of org.nxplanner.security.PersonPrincipal

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
        try {
            int myID = 0;
            String myUsername = null;

            PersonPrincipal me;
            try {
                me = (PersonPrincipal)(SecurityHelper.getUserPrincipal(req));
            } catch (AuthenticationException e) {
                res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
                return;
            }
            myID = me.getPerson().getId();
            myUsername = me.getPerson().getUserId();

            String requestedUsername = req.getPathInfo();
            if (requestedUsername == null || requestedUsername.equals("/")) {
                res.sendError(HttpServletResponse.SC_BAD_REQUEST, "No iCal file requested.");
                return;
View Full Code Here

Examples of org.nxplanner.security.PersonPrincipal

        return setUpSubject(person, roles);
    }

    public Subject setUpSubject(Person person, String[] roles) {
        Subject subject = new Subject();
        subject.getPrincipals().add(new PersonPrincipal(person));
        for (int i = 0; i < roles.length; i++) {
            if (roles[i] != null) {
                subject.getPrincipals().add(new Role(roles[i]));
            }
        }
View Full Code Here

Examples of org.nxplanner.security.PersonPrincipal

        HttpServletRequestSimulator request = new HttpServletRequestSimulator();
        HashSet principals = new HashSet();
        XPlannerProperties properties = new XPlannerProperties();
        String userId = getUserId() != null ?
                getUserId() : properties.getProperty("xplanner.test.user");
        principals.add(new PersonPrincipal(getPerson(ThreadSession.get(), userId)));
        SecurityHelper.setSubject(request, new Subject(true, principals, new HashSet(), new HashSet()));
        return request;
    }
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.