Package org.nemesis.forum.proxy

Source Code of org.nemesis.forum.proxy.ForumIteratorProxy

/*
* NEMESIS-FORUM.
* Copyright (C) 2002  David Laurent(lithium2@free.fr). All rights reserved.
*
* Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
*
* Copyright (C) 2001 Yasna.com. All rights reserved.
*
* Copyright (C) 2000 CoolServlets.com. All rights reserved.
*
* NEMESIS-FORUM. is free software; you can redistribute it and/or
* modify it under the terms of the Apache Software License, Version 1.1,
* or (at your option) any later version.
*
* NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
* application are parts of NEMESIS-FORUM and are distributed under
* same terms of licence.
*
*
* NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
* and software developed by CoolServlets.com (http://www.coolservlets.com).
* and software developed by Yasna.com (http://www.yasna.com).
*
*/
package org.nemesis.forum.proxy;

import java.util.ArrayList;
import java.util.Iterator;

import org.nemesis.forum.Authorization;
import org.nemesis.forum.Forum;
import org.nemesis.forum.ForumPermissions;
import org.nemesis.forum.config.Constants;

/**
* Protection proxy for Forum iterators. This is a special case iterator proxy
* because users might not have read access to some of the forums that we
* need to proxy. The expected behavior is that only forums that users <b>do</b>
* have read access for will be returned. Therefore, we need to read in the
* results and only return an iterator for forums that the user can read.
*/
class ForumIteratorProxy extends IteratorProxy {

  private ArrayList forums = new ArrayList();

  public ForumIteratorProxy(
    Iterator iterator,
    Authorization authorization,
    ForumPermissions permissions) {
    //Dummy call to super-class. This specialized iterator proxy doesn't
    //use the superclass like the other iterators do.
    super(iterator, authorization, permissions);

    while (iterator.hasNext()) {
      Forum forum = (Forum) iterator.next();
      ForumPermissions forumPermissions =
        forum.getPermissions(authorization);
      //Create a new permissions object with the combination of the
      //permissions of this object and tempPermissions.
      //Check and see if the user has READ permissions. If not, throw an
      //an UnauthorizedException.
     
      //AJOUT systemadmin
      if (forumPermissions.get(Constants.READ)
      || forumPermissions.get(Constants.SYSTEM_ADMIN)
      || forumPermissions.get(Constants.FORUM_ADMIN)
      || forumPermissions.get(Constants.MODERATOR)
      ) {
        ForumProxy proxy =
          new ForumProxy(forum, authorization, forumPermissions);
        forums.add(proxy);
      }
    }

    this.iterator = forums.listIterator();
  }

  public Object next() throws java.util.NoSuchElementException {
    return iterator.next();
  }
}
TOP

Related Classes of org.nemesis.forum.proxy.ForumIteratorProxy

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.