Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Identity


        du.setAttributeValue(doc, "/echo:entry/echo:link/@rel""alternate");
        du.setAttributeValue(doc, "/echo:entry/echo:link/@href", "http://bob.blog/");
        du.setAttributeValue(doc, "/echo:entry/echo:link/@type", "text/xml");

        // Replace author
        Identity identity = (Identity)parameters.get("org.apache.lenya.ac.Identity");
        du.setElementValue(doc, "/echo:entry/echo:author/echo:name", identity.getUser().getId());

        // Replace date created (and issued and modified, FIXME: issued should be set during first time publishing, modified should be set during re-publishing)
        DateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        DateFormat ofsfmt = new SimpleDateFormat("Z");
View Full Code Here


        if (!Arrays.asList(PARAMETER_NAMES).contains(name)) {
            throw new ConfigurationException("The attribute [" + name + "] is not supported!");
        }

        if (session != null) {
            Identity identity = (Identity) session.getAttribute(Identity.class.getName());
            if (identity != null) {
                if (name.equals(USER_ID)) {
                    User user = identity.getUser();
                    if (user != null) {
                        value = user.getId();
                    }
                } else if (name.equals(USER_NAME)) {
                    User user = identity.getUser();
                    if (user != null) {
                        value = user.getName();
                    }
                } else if (name.equals(USER_EMAIL)) {
                    User user = identity.getUser();
                    if (user != null) {
                        value = user.getEmail();
                    }
                } else if (name.equals(IP_ADDRESS)) {
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        value = machine.getIp();
                    }
                } else if (name.equals(ROLE_IDS)) {
                    try {
View Full Code Here

            Policy policy =
                policyManager.getPolicy(accessController.getAccreditableManager(), getUrl());
            UserManager userManager = accessController.getAccreditableManager().getUserManager();
            User[] userArray = userManager.getUsers();
            for (int i = 0; i < userArray.length; i++) {
                Identity identity = new Identity();
                identity.addIdentifiable(userArray[i]);
                Role[] roles = policy.getRoles(identity);
                for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
                    if (roles[roleIndex].getId().equals(roleId)) {
                        users.add(userArray[i]);
                    }
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();
            String remoteAddress = request.getRemoteAddr();
            String clientAddress = request.getHeader("x-forwarded-for");

            if (clientAddress != null) {
                Pattern p = Pattern.compile(REGEX);
                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 = 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()) {
                getLogger().debug("No such user: [" + username + "]");
View Full Code Here

        // is the document relly checked out).
        String step = parameters.getParameter("step");
               
        Session session = request.getSession(false);
        RCML rcml = getRc().getRCML(getFilename());
        Identity identity = (Identity) session.getAttribute(Identity.class
                .getName());

        if (step.equals("checkit")) {
            if (rcml.getLatestEntry().getType() != RCML.ci) {
                CheckOutEntry coe = rcml.getLatestCheckOutEntry();
                actionMap.put("user", coe.getIdentity());
                Date checkOutDate = new Date(coe.getTime());
                actionMap.put("date", checkOutDate.toString());
                actionMap.put("message", "lenya.rc.checkedoutalready");
                actionMap.put("state", "co");
            } else {
                CheckInEntry cie = rcml.getLatestCheckInEntry();
                actionMap.put("user", cie.getIdentity());
                Date checkInDate = new Date(cie.getTime());
                actionMap.put("date", checkInDate.toString());
                actionMap.put("message", "The resource has already been checked in by");   
                actionMap.put("state", "ci");
            }
            return actionMap;
        }

        rcml.checkOutIn(RCML.ci, identity.getUser().getId(), new Date().getTime(),
                false);

        return null;
    }
View Full Code Here

     */
    public boolean authorize(Request request)
        throws AccessControlException {

        Session session = request.getSession(true);
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Trying to authorize identity: " + identity);
        }

        boolean authorized;

        if (identity.belongsTo(getAccreditableManager())) {
            authorized = authorizePolicy(identity, request);
        } else {
            getLogger().debug(
                "Identity ["
                    + identity
View Full Code Here

     * Tests the identity.
     *
     * @throws AccessControlException if an error occurs
     */
    public void testIdentity() throws AccessControlException {
        Identity identity = new Identity();
        User user = getAccessController().getAccreditableManager().getUserManager().getUser(USER_ID);
        System.out.println("Adding user to identity: [" + user + "]");
        identity.addIdentifiable(user);
       
        assertSame(user, identity.getUser());
    }
View Full Code Here

        }
        Session session = request.getSession(false);
        if (session == null) {
            throw new WorkflowException("Session not initialized!");
        }
        Identity identity = Identity.getIdentity(session);
       
        return WorkflowFactory.newInstance().buildSituation(roles, 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.