Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Identity


     * @see org.apache.lenya.cms.cocoon.flow.FlowHelper#reservedCheckIn(org.apache.cocoon.components.flow.javascript.fom.FOM_Cocoon,
     *      boolean)
     */
    public void reservedCheckIn(FOM_Cocoon cocoon, boolean backup)
            throws FileReservedCheckInException, Exception {
        final Identity identity = (Identity) ObjectModelHelper.getRequest(cocoon.getObjectModel())
                .getSession().getAttribute(Identity.class.getName());
        final PageEnvelope pageEnvelope = getPageEnvelope(cocoon);
        final Publication publication = getPageEnvelope(cocoon).getPublication();
        final String filename = pageEnvelope.getDocument().getFile().getCanonicalPath()
                .substring(publication.getDirectory().getCanonicalPath().length());
        getRevisionController(cocoon).reservedCheckIn(filename,
                identity.getUser().getId(),
                backup,
                true);
    }
View Full Code Here


            getLogger().debug("Machine: [" + this.machineIp + "]");

            Request request = ContextHelper.getRequest(this.context);
            ((DefaultAccessController) controller).setupIdentity(request);
            Session session = request.getSession(false);
            Identity identity = (Identity) session.getAttribute(Identity.class.getName());
            Identifiable[] identifiables = identity.getIdentifiables();
            for (int i = 0; i < identifiables.length; i++) {
                identity.removeIdentifiable(identifiables[i]);
            }

            UserManager userManager = ((DefaultAccessController) controller)
                    .getAccreditableManager().getUserManager();
            if (this.userId != null) {
                User user = userManager.getUser(this.userId);

                if (user == null) {
                    throw new RuntimeException("User [" + this.userId + "] does not exist!");
                }

                identity.addIdentifiable(user);
            }
            if (this.machineIp != null) {
                Machine machine = new Machine(this.machineIp);
                identity.addIdentifiable(machine);
            }

            controller.authorize(request);

        } finally {
View Full Code Here

        super.initialize();
        DocumentIdentityMap map = new DocumentIdentityMap(this.manager, getLogger());
        getUnitOfWork().setIdentityMap(map);
        Request request = ContextHelper.getRequest(this.context);
        Session session = request.getSession(true);
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());
        getUnitOfWork().setIdentity(identity);
    }
View Full Code Here

            objects.put(UsecaseCronJob.SOURCE_URL, usecase.getSourceURL());

            Request request = ContextHelper.getRequest(this.context);
            Session session = request.getSession(false);
            if (session != null) {
                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                if (identity != null) {
                    User user = identity.getUser();
                    if (user != null) {
                        objects.put(UsecaseCronJob.USER_ID, user.getId());
                    }
                    Machine machine = identity.getMachine();
                    if (machine != null) {
                        objects.put(UsecaseCronJob.MACHINE_IP, machine.getIp());
                    }
                }
            }
View Full Code Here

        super.initParameters();

        Map objectModel = ContextHelper.getObjectModel(getContext());
        Request request = ObjectModelHelper.getRequest(objectModel);
        Session session = request.getSession(false);
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());
        User user = identity.getUser();
        if (user != null) {
            setParameter(DublinCore.ELEMENT_CREATOR, user.getId());
        } else {
            setParameter(DublinCore.ELEMENT_CREATOR, "");
        }
View Full Code Here

        Request request = ObjectModelHelper.getRequest(this.objectModel);
        Session session = request.getSession(false);

        Situation situation = null;
        if (session != null) {
            Identity identity = (Identity) session.getAttribute(Identity.class.getName());

            User user = identity.getUser();
            String userId = null;
            if (user != null) {
                userId = user.getId();
            }

            Machine machine = identity.getMachine();
            String machineIp = null;
            if (machine != null) {
                machineIp = machine.getIp();
            }
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

     * FIXME: Should this be exposed publically now that this method signature has been removed
     * from Authorizer?
     */
    public boolean authorize(Request request, String webappUrl) 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, webappUrl);
        } else {
            getLogger().debug(
                "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();
            identity.enableLogging(getLogger());
            identity.initialize();
            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 = 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

        this.identityMap = map;
    }

    protected String getUserId() {
        String userId = null;
        Identity identity = this.identityMap.getUnitOfWork().getIdentity();
        if (identity != null) {
            User user = identity.getUser();
            if (user != null) {
                userId = user.getId();
            }
        }
        return userId;
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.