Package it.eng.spagobi.wapp.util

Source Code of it.eng.spagobi.wapp.util.MenuAccessVerifier

package it.eng.spagobi.wapp.util;


import it.eng.spago.error.EMFInternalError;
import it.eng.spago.security.IEngUserProfile;
import it.eng.spagobi.commons.bo.Role;
import it.eng.spagobi.commons.bo.UserProfile;
import it.eng.spagobi.wapp.bo.Menu;

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

public class MenuAccessVerifier {



  public static boolean canView(Menu menu, IEngUserProfile profile) {

    Role[] menuRoles=menu.getRoles();
    Collection profileRoles=null;

    try {
      profileRoles = ((UserProfile)profile).getRolesForUse();
    } catch (EMFInternalError e) {
      return false;
    }


    boolean found=false;
    for (Iterator iterator = profileRoles.iterator(); iterator.hasNext() && !found;) {
      String profileRole = (String) iterator.next();
      for(int i=0;i<menuRoles.length && !found;i++){
        Role menuRole=menuRoles[i];
        String menuRoleName=menuRole.getName();

        if(menuRoleName.equals(profileRole)){
          found=true;
        }
      }

    }
    return found;


  }



}
TOP

Related Classes of it.eng.spagobi.wapp.util.MenuAccessVerifier

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.