Package it.eng.spagobi.services.security.bo

Examples of it.eng.spagobi.services.security.bo.SpagoBIUserProfile


     *
     * @return The User Profile Interface implementation object
     */
    public SpagoBIUserProfile createUserProfile(String userId) {
  logger.debug("IN.userId="+userId);
  SpagoBIUserProfile profile = new SpagoBIUserProfile();
  profile.setUniqueIdentifier(userId);
  profile.setUserId(userId);

  LDAPConnector conn = LdapConnectorFactory.createLDAPConnector();
  List ldapRoles = null;
  HashMap attributes = null;
  try {
      ldapRoles = conn.getUserGroup(userId);
      attributes = conn.getUserAttributes(userId);
  } catch (UnsupportedEncodingException e) {
      logger.error("UnsupportedEncodingException", e);
  } catch (LDAPException e) {
      logger.error("LDAPException", e);
  }
  Iterator iterRoles = ldapRoles.iterator();
  List roles = new ArrayList();
 
  while (iterRoles.hasNext()) {
      String roleName = (String) iterRoles.next();
      logger.debug("RoleName from LDAP:"+roleName);
      if (roleName!=null && !roleName.equals("Group")){
    Role role = new Role(roleName, roleName);
    roles.add(role);
      }
     
  }

  String[] roleStr = new String[roles.size()];
  for (int i = 0; i < roles.size(); i++) {
      roleStr[i] = (String) ((Role)roles.get(i)).getName();
  }
  profile.setRoles(roleStr);
  profile.setAttributes(createMapAttributes(attributes));
 

  logger.debug("OUT");

  return profile;
View Full Code Here


   * @return The User Profile Interface implementation object
   */

  public SpagoBIUserProfile createUserProfile(String userId) {
    logger.debug("IN,userId="+userId);
    SpagoBIUserProfile profile = new SpagoBIUserProfile();
    profile.setUniqueIdentifier(userId);
    profile.setUserId(userId);
   

    try {
     
      UserServiceSoapServiceLocator uService = new UserServiceSoapServiceLocator();
      UserServiceSoap userService = uService.getPortal_UserService(_getURL("Portal_UserService"));
      UserSoap user = userService.getUserById(Integer.parseInt(userId));  

      if (user != null) {
        // user attributes
        HashMap<String, String> userAttributes = new HashMap<String, String>();

        userAttributes.put("USER_ID", String.valueOf(user.getUserId()));
        userAttributes.put("NAME", user.getFirstName());
        userAttributes.put("SURNAME", user.getLastName());
        userAttributes.put("E_MAIL", user.getEmailAddress());

        //set up the userID with email - adress
        profile.setUserName(user.getEmailAddress());
        profile.setUserId(user.getEmailAddress());
       
        logger.debug("user.getUserId()="+ user.getUserId());
        logger.debug("user.getScreenName()="+ user.getScreenName());
        logger.debug( "user.getFirstName()="+ user.getFirstName());
        logger.debug( "user.getLastName()="+ user.getLastName());

        profile.setAttributes(userAttributes);

        // user roles
        RoleServiceSoapServiceLocator rService = new RoleServiceSoapServiceLocator();
        RoleServiceSoap roleService = rService.getPortal_RoleService(_getURL("Portal_RoleService"));
        RoleSoap[] roles = roleService.getUserRoles(Integer.parseInt(userId));
        String[] roleNames = new String[roles.length];
        if (roles != null) {
          int i = 0;
          while (i<roles.length) {
              RoleSoap role=roles[i];
            logger.debug("ruolo.getName()="+ role.getName());
            logger.debug("ruolo.getDescription()="+ role.getDescription());
            logger.debug("ruolo.getRoleId()=" + role.getRoleId());
            roleNames[i++] = role.getName();
          }
        }
        else {
          logger.warn("THE LIST OF ROLES IS EMPTY, CHECK THE PROFILING CONFIGURATION...");
        }
        profile.setRoles(roleNames);
      }

    }

    catch (RemoteException e) {
View Full Code Here

  public static IEngUserProfile createNewUserProfile(String userId) throws Exception {
    logger.debug("IN");
    IEngUserProfile profile = null;
    try {
      ISecurityServiceSupplier supplier = SecurityServiceSupplierFactory.createISecurityServiceSupplier();
      SpagoBIUserProfile user = supplier.createUserProfile(userId);
      user.setFunctions(UserUtilities.readFunctionality(user.getRoles()));
      profile = new UserProfile(user);
    } catch (Exception e) {
      logger.error("An error occurred while creating user profile for user [" + userId + "]");
      throw new SecurityException("An error occurred while creating user profile for user [" + userId + "]", e);
    } finally {
View Full Code Here

      Principal principal = portletRequest.getUserPrincipal();
      userId = principal.getName();
      logger.debug("got userId from Principal=" + userId);

      ISecurityServiceSupplier supplier = SecurityServiceSupplierFactory.createISecurityServiceSupplier();
      SpagoBIUserProfile user = null;
      try {
    user = supplier.createUserProfile(userId);
   
    user.setFunctions(readFunctionality(user.getRoles()));
    userProfile = new UserProfile(user);
      } catch (Exception e) {
        logger.error("An error occured while retrieving user profile for user[" + userId +"]");
        throw new SecurityException("An error occured while retrieving user profile for user[" + userId +"]", e);
      }

      logger.debug("userProfile created.UserID= " + (String) userProfile.getUserUniqueIdentifier());
      logger.debug("Attributes name of the user profile: " + userProfile.getUserAttributeNames());
      logger.debug("Functionalities of the user profile: " + userProfile.getFunctionalities());
      logger.debug("Roles of the user profile: " + userProfile.getRoles());

      permanentSession.setAttribute(IEngUserProfile.ENG_USER_PROFILE, userProfile);

     // String username = (String) userProfile.getUserUniqueIdentifier();
      String username = (String) user.getUserId();
      if (!UserUtilities.userFunctionalityRootExists(username)) {
    UserUtilities.createUserFunctionalityRoot(userProfile);
      }

  }
View Full Code Here

      SsoServiceInterface userProxy = SsoServiceFactory.createProxyService();
    String userId = userProxy.readUserIdentifier(req);
   
      ISecurityServiceSupplier supplier = SecurityServiceSupplierFactory.createISecurityServiceSupplier();
      try {
    SpagoBIUserProfile user = supplier.createUserProfile(userId);
    user.setFunctions(readFunctionality(user.getRoles()));
    return new UserProfile(user);
      } catch (Exception e) {
        logger.error("Exception while creating user profile",e);
      throw new SecurityException("Exception while creating user profile", e);
      }finally{
View Full Code Here

    public static IEngUserProfile getUserProfile(String userId) throws Exception {
      logger.debug("IN.userId="+userId);
      if (userId==null) return null;
      ISecurityServiceSupplier supplier = SecurityServiceSupplierFactory.createISecurityServiceSupplier();
      try {
    SpagoBIUserProfile user = supplier.createUserProfile(userId);
    if (user==null) return null;
    user.setFunctions(readFunctionality(user.getRoles()));
    return new UserProfile(user);
      } catch (Exception e) {
        logger.error("Exception while creating user profile",e);
      throw new SecurityException("Exception while creating user profile", e);
      }finally{
View Full Code Here

  return false;
    }

    private SpagoBIUserProfile createSpagoBIUserProfile(String userId) {
  logger.debug("IN. userId=" + userId);
  SpagoBIUserProfile profile = new SpagoBIUserProfile();
  try {
    profile.setUniqueIdentifier(userId);
      profile.setUserId(userId);
      ArrayList roles = new ArrayList();
      HashMap userAttributes = new HashMap();
      PortalContainer container = PortalContainer.getInstance();

      if (container == null) {
    ConfigSingleton config = ConfigSingleton.getInstance();
    SourceBean securityconfSB = (SourceBean) config
      .getAttribute("SPAGOBI.SECURITY.PORTAL-SECURITY-CLASS.CONFIG");
    String paramCont = "NAME_PORTAL_APPLICATION";
    SecurityProviderUtilities.debug(this.getClass(), "<init(Principal)>", " Use param " + paramCont);
    SourceBean paramContSB = (SourceBean) securityconfSB.getAttribute(paramCont);
    SecurityProviderUtilities.debug(this.getClass(), "<init(Principal)>",
      " Param context name Source Bean " + "retrived: " + paramContSB);
    String nameCont = (String) paramContSB.getCharacters();
    SecurityProviderUtilities.debug(this.getClass(), "<init(Principal)>", " Use context name " + nameCont);
    RootContainer rootCont = RootContainer.getInstance();
    SecurityProviderUtilities.debug(this.getClass(), "<init(Principal)>", " Root container retrived: "
      + rootCont);
    container = rootCont.getPortalContainer(nameCont);
      }

      OrganizationService service = (OrganizationService) container
        .getComponentInstanceOfType(OrganizationService.class);

      // load user roles
      Collection tmpRoles = service.getGroupHandler().findGroupsOfUser(userId);
      GroupHandler groupHandler = service.getGroupHandler();
      SecurityProviderUtilities.debug(this.getClass(), "init", "Group Handler retrived " + groupHandler);
      MembershipHandler memberHandler = service.getMembershipHandler();
      SecurityProviderUtilities.debug(this.getClass(), "init", "Membership Handler retrived " + memberHandler);
      Group group = null;
      Matcher matcher = null;
      for (Iterator it = tmpRoles.iterator(); it.hasNext();) {
    group = (Group) it.next();
    String groupID = group.getId();
    Pattern pattern = SecurityProviderUtilities.getFilterPattern();
    matcher = pattern.matcher(groupID);
    if (!matcher.find()) {
        continue;
    }
    roles.add(group.getId());
    logger.debug("Roles load into SpagoBI profile: " + group.getId());
      }

      // start load profile attributes
      userAttributes = SecurityProviderUtilities.getUserProfileAttributes(userId, service);
      logger.debug("Attributes load into SpagoBI profile: " + userAttributes);
      // end load profile attributes
     
      profile.setAttributes(userAttributes);
     
      if (roles.size()==0){
       logger.warn("THE LIST OF ROLES IS EMPTY, CHECK THE PROFILING CONFIGURATION...");
      }else {
              String[] roleStr = new String[roles.size()];
              for (int i = 0; i < roles.size(); i++) {
            roleStr[i] = (String) roles.get(i);
              }
              profile.setRoles(roleStr);
           
      }
  } catch (Exception e) {
      logger.error("Exception", e);
  }finally{
View Full Code Here

TOP

Related Classes of it.eng.spagobi.services.security.bo.SpagoBIUserProfile

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.