Package org.jasig.portal.security

Examples of org.jasig.portal.security.IPerson


                if (userView != null) {
                    int userId  = userView.getUserId();
   
                    if ( null != ownerId )
                    {
                        IPerson p = new PersonImpl();
                        p.setID( userId );
                        p.setAttribute( "username", ownerId );
                        owners.put(p, fragmentDefinition);
                    }
                }
            }

            // cycle through each layout owner and clear out their
            // respective layouts so users fragments will be cleared
            for (final Map.Entry<IPerson, FragmentDefinition> ownerEntry : owners.entrySet()) {
                final IPerson person = ownerEntry.getKey();
                final UserProfile profile;
                try {
                    profile = getUserProfileByFname(person, "default");
                }
                catch (Exception e) {
View Full Code Here


       
    @SuppressWarnings("unchecked")
    public void importLayout(org.dom4j.Element layout) {
       
        String ownerUsername = layout.valueOf("@username");
        IPerson person = null;
        UserProfile profile = null;
        try {
            person = new PersonImpl();
            person.setUserName(ownerUsername);
            int ownerId = identityStore.getPortalUID(person);
            if (ownerId == -1) {
                String msg = "No userId for username=" + ownerUsername;
                throw new RuntimeException(msg);
            }
            person.setID(ownerId);
            person.setSecurityContext(new BrokenSecurityContext());
            profile = this.getUserProfileByFname(person, "default");
        } catch (Throwable t) {
            String msg = "Unrecognized user " + person.getUserName() + "; you must import users before their layouts.";
            throw new RuntimeException(msg, t);
        }
       
        // (6) Add database Ids & (5) Add dlm:plfID ...
        int nextId = 1;
        for (Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout.selectNodes("folder | dlm:*").iterator(); it.hasNext();) {
            nextId = addIdAttributesIfNecessary(it.next(), nextId);
        }
        // Now update UP_USER...
        final SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(RDBMServices.getDataSource());
        jdbcTemplate.update("UPDATE up_user SET next_struct_id = ? WHERE user_id = ?", nextId, person.getID());

        // (4) Convert external DLM pathrefs to internal form (noderefs)...
        for (Iterator<org.dom4j.Attribute> itr = (Iterator<org.dom4j.Attribute>) layout.selectNodes("//@dlm:origin").iterator(); itr.hasNext();) {
            org.dom4j.Attribute a = itr.next();
            String noderef = getDlmNoderef(ownerUsername, a.getValue(), null, true, layout);
            if (noderef != null) {
                // Change the value only if we have a valid pathref...
                a.setValue(noderef);
                // For dlm:origin only, also use the noderef as the ID attribute...
                a.getParent().addAttribute("ID", noderef);
            }
         }
        for (Iterator<org.dom4j.Attribute> itr = (Iterator<org.dom4j.Attribute>) layout.selectNodes("//@dlm:target").iterator(); itr.hasNext();) {
            org.dom4j.Attribute a = itr.next();
            String noderef = getDlmNoderef(ownerUsername, a.getValue(), null, true, layout);
            if (noderef != null) {
                // Change the value only if we have a valid pathref...
                a.setValue(noderef);
            }
        }
        for (Iterator<org.dom4j.Attribute> names = (Iterator<org.dom4j.Attribute>) layout.selectNodes("//dlm:*/@name").iterator(); names.hasNext();) {
            org.dom4j.Attribute a = names.next();
            org.dom4j.Attribute fname = a.getParent().attribute("fname");
            String noderef = null;
            if (fname != null) {
                noderef = getDlmNoderef(ownerUsername, a.getValue(), fname.getValue(), false, layout);
                // Remove the fname attribute now that we're done w/ it...
                fname.getParent().remove(fname);
            } else {
                noderef = getDlmNoderef(ownerUsername, a.getValue(), null, true, layout);
            }
            if (noderef != null) {
                // Change the value only if we have a valid pathref...
                a.setValue(noderef);
            }
        }

        // (3) Restore chanID attributes on <channel> elements...
        for (Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout.selectNodes("//channel").iterator(); it.hasNext();) {
            org.dom4j.Element c = it.next();
            final String fname = c.valueOf("@fname");
            IChannelDefinition cd = this.channelRegistryStore.getChannelDefinition(fname);
            if (cd == null) {
                throw new IllegalArgumentException("No published channel for fname=" + fname + " referenced by layout for " + ownerUsername);
            }
            c.addAttribute("chanID", String.valueOf(cd.getId()));
        }
       
        // (2) Restore locale info...
        // (This step doesn't appear to be needed for imports)

        // (1) Process structure & theme attributes...
        Document layoutDom = null;
        try {

//            UserPreferences up = this.getUserPreferences(person, profile);
            UserPreferences up = new UserPreferences(profile);
            up.setStructureStylesheetUserPreferences(this.getDistributedSSUP(person,
                        profile.getProfileId(), profile.getStructureStylesheetId()));
            up.setThemeStylesheetUserPreferences(this.getDistributedTSUP(person,
                        profile.getProfileId(), profile.getThemeStylesheetId()));
           
            // Structure Attributes.
            boolean saSet = false;
            StructureStylesheetUserPreferences ssup = up.getStructureStylesheetUserPreferences();
            // ssup must be manually cleaned out.
            for (Enumeration<String> names = (Enumeration<String>) ssup.getFolderAttributeNames(); names.hasMoreElements();) {
                String n = names.nextElement();
                for (Enumeration<String> fIds = (Enumeration<String>) ssup.getFolders(); fIds.hasMoreElements();) {
                    String f = fIds.nextElement();
                    if (ssup.getDefinedFolderAttributeValue(f, n) != null) {
                        ssup.removeFolder(f);
                    }
                }
            }
            for (Enumeration<String> names = (Enumeration<String>) ssup.getChannelAttributeNames(); names.hasMoreElements();) {
                String n = names.nextElement();
                for (Enumeration<String> chds = (Enumeration<String>) ssup.getChannels(); chds.hasMoreElements();) {
                    String c = chds.nextElement();
                    if (ssup.getDefinedChannelAttributeValue(c, n) != null) {
                        ssup.removeChannel(c);
                    }
                }
            }
            for (Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout.selectNodes("//structure-attribute").iterator(); it.hasNext();) {
                org.dom4j.Element sa = (org.dom4j.Element) it.next();
                String idAttr = sa.getParent().valueOf("@ID");
                if (sa.getParent().getName().equals("folder")) {
                    ssup.setFolderAttributeValue(idAttr, sa.valueOf("name"), sa.valueOf("value"));
                    saSet = true;
                } else if (sa.getParent().getName().equals("channel")) {
                    ssup.setChannelAttributeValue(idAttr, sa.valueOf("name"), sa.valueOf("value"));
                    saSet = true;
                } else {
                    String msg = "Unrecognized parent element for user preferences attribute:  " + sa.getParent().getName();
                    throw new RuntimeException(msg);
                }
                // Remove these elements or else DLM will choke...
                sa.getParent().remove(sa);
            }
           
            // Theme Attributes.
            boolean taSet = false;
            ThemeStylesheetUserPreferences tsup = up.getThemeStylesheetUserPreferences();
            // tsup must be manually cleaned out.
            for (Enumeration<String> names = (Enumeration<String>) tsup.getChannelAttributeNames(); names.hasMoreElements();) {
                String n = names.nextElement();
                for (Enumeration<String> chds = (Enumeration<String>) tsup.getChannels(); chds.hasMoreElements();) {
                    String c = chds.nextElement();
                    if (tsup.getDefinedChannelAttributeValue(c, n) != null) {
                        tsup.removeChannel(c);
                    }
                }
            }
            for (Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout.selectNodes("//theme-attribute").iterator(); it.hasNext();) {
                org.dom4j.Element ta = (org.dom4j.Element) it.next();
                String idAttr = ta.getParent().valueOf("@ID");
                // Theme attributes are channels only...
                tsup.setChannelAttributeValue(idAttr, ta.valueOf("name"), ta.valueOf("value"));
                taSet = true;
                // Remove these elements or else DLM will choke...
                ta.getParent().remove(ta);
            }

            // From this point forward we need the user's PLF set as DLM expects it...
            for (Iterator<org.dom4j.Text> it = (Iterator<org.dom4j.Text>) layout.selectNodes("descendant::text()").iterator(); it.hasNext();) {
                // How many years have we used Java & XML, and this still isn't easy?
                org.dom4j.Text txt = it.next();
                if (txt.getText().trim().length() == 0) {
                    txt.getParent().remove(txt);
                }
            }
           
            org.dom4j.Element copy = layout.createCopy();
            org.dom4j.Document doc = fac.createDocument(copy);
            doc.normalize();
            layoutDom = writer.write(doc);
            person.setAttribute(Constants.PLF, layoutDom);

            if (saSet) {
              this.setStructureStylesheetUserPreferences(person, profile.getProfileId(), ssup);
            }
            if (taSet) {
                this.setThemeStylesheetUserPreferences(person, profile.getProfileId(), tsup);
            }
           
        } catch (Throwable t) {
            log.error("Unable to set UserPreferences for user:  " + person.getUserName());
            throw new RuntimeException(t);
        }
       
        // Finally store the layout...
        try {
View Full Code Here

                        rs.next();
                        userId = rs.getInt(1);
                       
                        // get the profile ID for the default user
                        UserProfile profile = getUserProfileById(person, profileId);
                    IPerson defaultProfilePerson = new PersonImpl();
                    defaultProfilePerson.setID(userId);
                        profileId = getUserProfileByFname(defaultProfilePerson, profile.getProfileFname()).getProfileId();

                    } finally {
                        close(rs);
                    }
View Full Code Here

                // save
                String skinName = runtimeData.getParameter("skinName");
                ThemeStylesheetUserPreferences themePrefs = userPrefs.getThemeStylesheetUserPreferences();
                themePrefs.putParameterValue("skin",skinName);
               
                final IPerson person = staticData.getPerson();
                final UserProfile profile = userPrefs.getProfile();
                final int profileId = profile.getProfileId();
                try {
                    ulStore.setThemeStylesheetUserPreferences(person, profileId, themePrefs);
                } catch (Exception e) {
View Full Code Here

                        rs.next();
                        userId = rs.getInt(1);
                       
                        // get the profile ID for the default user
                        UserProfile profile = getUserProfileById(person, profileId);
                    IPerson defaultProfilePerson = new PersonImpl();
                    defaultProfilePerson.setID(userId);
                        profileId = getUserProfileByFname(defaultProfilePerson, profile.getProfileFname()).getProfileId();

                    } finally
                    {
                        close(rs);
View Full Code Here

      }
  }// setUserPassword

  public void removeUser( IPerson AnIndividual ) throws Exception {

       IPerson per= new PersonImpl();
       per.setAttribute(IPerson.USERNAME, AnIndividual.getAttribute( Constants.UNFIELD ));

       int portalUID = -1;
       try{
          portalUID = rdbmuser.getPortalUID(per, false);
       }catch(org.jasig.portal.AuthorizationException ae) { /* do nothing */ }
View Full Code Here

  }// runQuery

  private IPerson[] mkIPeople( ResultSet R ) throws Exception {

     Vector v = new Vector();
     IPerson person = null;

     while( R.next() ){

       person = new PersonImpl();

       for( int i = 1; i <= R.getMetaData().getColumnCount(); i++ ) {

           if( R.getMetaData().getColumnType( i ) != Types.TIMESTAMP )
             person.setAttribute(
                   R.getMetaData().getColumnName( i ).toLowerCase(),
                      (R.getString( i )==null?"":R.getString( i )));
            else
             person.setAttribute(
                   R.getMetaData().getColumnName( i ).toLowerCase(),
                      (R.getString( i )==null?"": RDBMServices.getDbMetaData().sqlTimeStamp(
                         new java.util.Date( R.getTimestamp( i ).getTime()) )));

       }// for

       v.addElement( person );
     }// while

     IPerson pwdtst = null;
     IPerson[] people = new IPerson[ v.size() ];
     for( int i = 0; i < people.length; i++ ) {
       people[ i ] = (IPerson)v.elementAt( i );

       // if the user exists but has no layout information, the account
       // is considered to be locked, this is technically inaccurate
       try{
         pwdtst = new PersonImpl();

         pwdtst.setAttribute( IPerson.USERNAME,
              people[ i ].getAttribute( Constants.UNFIELD ));

         rdbmuser.getPortalUID( pwdtst, false );
       }catch(org.jasig.portal.AuthorizationException ae) {
View Full Code Here

     */
    @Override
    public PortletDelegationDispatcher createRequestDispatcher(PortletRequest portletRequest, IPortletDefinitionId portletDefinitionId) {
        final HttpServletRequest request = this.portalRequestUtils.getOriginalPortalRequest(portletRequest);
        final HttpServletResponse response = this.portalRequestUtils.getOriginalPortalResponse(portletRequest);
        final IPerson person = this.personManager.getPerson(request);
       
        final String transientChannelSubscribeId = "CONFIG_" + portletDefinitionId;
        final IPortletEntity portletEntity = this.portletEntityRegistry.getOrCreatePortletEntity(portletDefinitionId, transientChannelSubscribeId, person.getID());
       
        final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();

        final InternalPortletWindow internalPortletWindow = ((InternalPortletRequest)portletRequest).getInternalPortletWindow();
        final IPortletWindow parentPortletWindow = this.portletWindowRegistry.convertPortletWindow(request, internalPortletWindow);
        final IPortletWindowId parentPortletWindowId = parentPortletWindow.getPortletWindowId();
        final IPortletWindow portletWindow = this.portletWindowRegistry.createDelegatePortletWindow(request, portletEntityId, parentPortletWindowId);

        //Initialize the window since we just created it
        final ContainerInvocation invocation = ContainerInvocation.getInvocation();
        try {
            this.portletRenderer.doInit(portletEntity, portletWindow.getPortletWindowId(), request, response);
        }
        finally {
            if (invocation != null) {
                ContainerInvocation.setInvocation(invocation.getPortletContainer(), invocation.getPortletWindow());
            }
        }
       
        return new PortletDelegationDispatcherImpl(portletWindow, parentPortletWindow, person.getID(), this.portalRequestUtils, this.personManager, this.portletRenderer, this.portletRequestParameterManager, this);
    }
View Full Code Here

     * @see org.jasig.portal.api.portlet.PortletDelegationLocator#getRequestDispatcher(org.jasig.portal.portlet.om.IPortletWindowId)
     */
    @Override
    public PortletDelegationDispatcher getRequestDispatcher(PortletRequest portletRequest, IPortletWindowId portletWindowId) {
        final HttpServletRequest request = this.portalRequestUtils.getOriginalPortalRequest(portletRequest);
        final IPerson person = this.personManager.getPerson(request);
       
        final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
       
        final IPortletWindowId delegationParentId = portletWindow.getDelegationParent();
        if (delegationParentId == null) {
            throw new IllegalArgumentException("Portlet window '" + portletWindow + "' is not a delegate window and cannot be delgated to.");
        }
       
        final IPortletWindow parentPortletWindow = this.portletWindowRegistry.getPortletWindow(request, delegationParentId);
       
        return new PortletDelegationDispatcherImpl(portletWindow, parentPortletWindow, person.getID(), this.portalRequestUtils, this.personManager, this.portletRenderer, this.portletRequestParameterManager, this);
    }
View Full Code Here

        seedValue.add(ei.getKey());
        seed.put(IPerson.USERNAME, seedValue);
        Map<String,List<Object>> attr = PersonDirectory.getPersonAttributeDao().getMultivaluedUserAttributes(seed);
            // avoid NPEs and unnecessary IPerson creation
            if (attr != null && !attr.isEmpty()) {
                IPerson p = PersonFactory.createPerson();
                p.setAttributes(attr);

                // Analyze its memberships...
                String attrName = (String) spring_context.getBean("memberOfAttributeName");
                Object groupKeys = p.getAttributeValues(attrName);
                // IPerson returns null if no value is defined for this attribute...
                if (groupKeys != null) {

                    List<String> list = new LinkedList<String>();
                    if (groupKeys instanceof String) {
View Full Code Here

TOP

Related Classes of org.jasig.portal.security.IPerson

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.