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 (session == null) {
                    throw new Exception("No session");
                }

                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                User user = identity.getUser();
                String userId = "";
                if (user != null) {
                    userId = user.getId();
                }
                rc.reservedCheckIn(xmlRoot + "/" + relativeFilename, userId, true);
View Full Code Here

                if (session == null) {
                    throw new Exception("No session");
                }

                Identity identity = (Identity) session.getAttribute(Identity.class.getName());
                org.apache.lenya.ac.Identity identityTwo =
                    (org.apache.lenya.ac.Identity) session.getAttribute(Identity.class.getName());
                String username = null;
                if (identity != null) {
                    User user = identity.getUser();
                    if (user != null) {
                        username = user.getId();
                    }
                } else if (identityTwo != null) {
                    username = identityTwo.getUser().getId();
View Full Code Here

     * @throws AccessControlException when something went wrong.
     */
    public Situation getSituation(FOM_Cocoon cocoon) throws AccessControlException {
        Request request = ObjectModelHelper.getRequest(cocoon.getObjectModel());
        Session session = request.getSession();
        Identity identity = (Identity) session.getAttribute(Identity.class.getName());

        String userId = "";
        String ipAddress = "";

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

        Machine machine = identity.getMachine();
        if (machine != null) {
            ipAddress = machine.getIp();
        }

        Role[] roles = PolicyAuthorizer.getRoles(request);
View Full Code Here

            instance = factory.buildInstance(document);
            assertNotNull(instance);

            System.out.println("Current state: " + instance.getCurrentState());

            Identity identity = new Identity();
            User user =
                getAccreditableManager().getUserManager().getUser(
                    situations[situationIndex].getUser());
            identity.addIdentifiable(user);

            Role[] roles = policy.getRoles(identity);
            System.out.print("Roles:");

            for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
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

    protected Identity getIdentity() throws AccessControlException {
        DefaultAccessController controller = getAccessController();
        User user = controller.getAccreditableManager().getUserManager().getUser(USERNAME);
        assertNotNull(user);

        Identity identity = new Identity();
        identity.addIdentifiable(user);

        return identity;
    }
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

   * @see org.apache.lenya.cms.ac2.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();

            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

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.