Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Identity


     * @return A boolean value.
     * @throws AccessControlException when something went wrong.
     */
    protected boolean hasValidIdentity(Session session) throws AccessControlException {
        boolean valid = true;
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());
        if (identity == null || !ownsIdenity(identity)) {
            valid = false;
        }
        return valid;
    }
View Full Code Here


        if (getLogger().isDebugEnabled()) {
            getLogger().debug(
                    "Authenticating username [" + username + "]");
        }

        Identity identity = (Identity) request.getSession(false).getAttribute(Identity.class.getName());

        User user = accreditableManager.getUserManager().getUser(username);

        boolean authenticated = false;
        if (user != null) {
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("User [" + user + "] authenticated.");
            }

            if (!identity.contains(user)) {
                User oldUser = identity.getUser();
                if (oldUser != null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("Removing user [" + oldUser + "] from identity.");
                    }
                    identity.removeIdentifiable(oldUser);
                }
                identity.addIdentifiable(user);
            }
            authenticated = true;
        } else {
            if (getLogger().isDebugEnabled()) {
                if (user == null) {
View Full Code Here

        if (username == null || password == null) {
            throw new AccessControlException("Username or password is null!");
        }

        Identity identity = (Identity) request.getSession(false).getAttribute(
                Identity.class.getName());

        if (identity == null) {
            throw new AccessControlException("The session does not contain the identity!");
        }
View Full Code Here

    }

    protected void resolveRoles(Request request) throws AccessControlException {
        String webappUrl = ServletHelper.getWebappURI(request);
        Session session = request.getSession(true);
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());

        Role[] roles;
        if (identity.belongsTo(this.accreditableManager)) {
            roles = this.policyManager.getGrantedRoles(this.accreditableManager, identity, webappUrl);
        } else {
            roles = new Role[0];
            getLogger().debug(
                    "No roles resolved for identity [" + identity
View Full Code Here

     * @see org.apache.lenya.ac.AccessController#setupIdentity(org.apache.cocoon.environment.Request)
     */
    public void setupIdentity(Request request) throws AccessControlException {
        Session session = request.getSession(true);
        if (!hasValidIdentity(session)) {
            Identity identity = new Identity(getLogger());
            identity.initialize();
            String remoteAddress = request.getRemoteAddr();
            String clientAddress = request.getHeader("x-forwarded-for");

            if (clientAddress != null) {
                Pattern p = Pattern.compile(VALID_IP);
                Matcher m = p.matcher(clientAddress);

                if (m.find()) {
                    remoteAddress = m.group();
                }
            }

            getLogger().info("Remote Address to use: [" + remoteAddress + "]");

            Machine machine = new Machine(remoteAddress);
            IPRange[] ranges = this.accreditableManager.getIPRangeManager().getIPRanges();
            for (int i = 0; i < ranges.length; i++) {
                if (ranges[i].contains(machine)) {
                    machine.addIPRange(ranges[i]);
                }
            }

            identity.addIdentifiable(machine);
            session.setAttribute(Identity.class.getName(), identity);
        }
    }
View Full Code Here

     * @return A boolean value.
     * @throws AccessControlException when something went wrong.
     */
    protected boolean hasValidIdentity(Session session) throws AccessControlException {
        boolean valid = true;
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());
        if (identity == null || !ownsIdenity(identity)) {
            valid = false;
        }
        return valid;
    }
View Full Code Here

        if (getLogger().isDebugEnabled()) {
            getLogger().debug(
                    "Authenticating username [" + username + "]");
        }

        Identity identity = (Identity) request.getSession(false).getAttribute(Identity.class.getName());

        User user = accreditableManager.getUserManager().getUser(username);

        boolean authenticated = false;
        if (user != null) {
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("User [" + user + "] authenticated.");
            }

            if (!identity.contains(user)) {
                User oldUser = identity.getUser();
                if (oldUser != null) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("Removing user [" + oldUser + "] from identity.");
                    }
                    identity.removeIdentifiable(oldUser);
                }
                identity.addIdentifiable(user);
            }
            authenticated = true;
        } else {
            if (getLogger().isDebugEnabled()) {
                if (user == null) {
View Full Code Here

        setParameter(USERS, userList);
       
        Request request = ContextHelper.getRequest(getContext());
        Session session = request.getSession(false);
        if (session != null) {
            Identity identity = (Identity) session.getAttribute(Identity.class.getName());
            if (identity != null) {
                setParameter(CURRENT_USER, identity.getUser());
            }
        }
       
        UserType[] types = getUserManager().getUserTypes();
        setParameter(USER_TYPES, Arrays.asList(types));
View Full Code Here

        Iterator userit = allSessions.entrySet().iterator();
        while (userit.hasNext()) {
            Map.Entry entry = (Map.Entry) userit.next();
            HttpSession nextsession = (HttpSession) entry.getValue();

            Identity identity = (Identity) nextsession.getAttribute(IDENTITY);
           
            if(identity == null) {
                continue;
            }  
         
            User user = identity.getUser();
            if (user != null) {
                Vector history = (Vector) nextsession.getAttribute(HISTORY);
                String publicationID = getPublicationIDfromHistory(history);
                if (publicationID.equals(getPublicationIDfromURL())) {
                    userList.add(identity.getUser());
                }
            }
        }
        setParameter(USERS, userList);
    }
View Full Code Here

        if (username == null || password == null) {
            throw new AccessControlException("Username or password is null!");
        }

        Identity identity = (Identity) request.getSession(false).getAttribute(
                Identity.class.getName());

        if (identity == null) {
            throw new AccessControlException("The session does not contain the identity!");
        }
View Full Code Here

TOP

Related Classes of org.apache.lenya.ac.Identity

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.