<commit_before>/* Copyright 2005 The JA-SIG Collaborative.  All rights reserved.
*  See license distributed with this file and
*  available online at http://www.uportal.org/license.html
*/
package org.jasig.portal.channels.cusermanager;

import java.util.Enumeration;
import java.text.MessageFormat;

import org.jasig.portal.IChannel;

import org.jasig.portal.security.IPerson;
import org.jasig.portal.security.IPermission;
import org.jasig.portal.security.provider.PersonImpl;
//import edu.cornell.uportal.channels.cusermanager.provider.PersonImpl;

import org.jasig.portal.ChannelStaticData;
import org.jasig.portal.ChannelRuntimeData;
import org.jasig.portal.ChannelRuntimeProperties;
import org.jasig.portal.PortalEvent;
import org.jasig.portal.PortalException;
import org.jasig.portal.IPermissible;
import org.jasig.portal.AuthorizationException;

import org.jasig.portal.utils.XSLT;
import org.jasig.portal.utils.DocumentFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import org.xml.sax.ContentHandler;

/**
 * @author <EMAIL>
 * @version $Revision$ $Date$
 */
public class CUserManager extends CUserManagerPermissions implements IChannel, IPermissible {

  private IDataHandler datasource;

  private String mode = Constants.MODEDISPLAY;

  private ChannelStaticData channelStaticData;
  private ChannelRuntimeData channelRuntimeData;

  private boolean ManagerMode = false;
  private boolean PwdChngMode = true;

  private PortalEvent lastEvent;

  /** for pwd chng mode, we want to cache the user's info because
   *  there will be many more of these than admin channels
   */
  private Document PersonalDocument = null;

  /**
   */
  public CUserManager() {
  }// CUserManager

  /**
   *  Returns channel runtime properties.
   *  Satisfies implementation of Channel Interface.
   *
   *  @return handle to runtime properties
   */
  public ChannelRuntimeProperties getRuntimeProperties() {
    return new ChannelRuntimeProperties();
  }// getRuntimeProperties

  /**
   *  Process layout-level events coming from the portal.
   *  Satisfies implementation of IChannel Interface.
   *
   *  @param ev <b>PortalEvent</b> a portal layout event
   */
  public void receiveEvent(PortalEvent ev) {

    this.lastEvent = ev;

  }// receiveEvent

  /**
   *  Receive static channel data from the portal.
   *  Satisfies implementation of IChannel Interface.
   *
   *  @param sd <b>ChannelStaticData</b> static channel data
   */
  public void setStaticData(ChannelStaticData sd) {
    channelStaticData = sd;

// Ignore since 2.0 (2003.04.21)
//    if( CSD.getParameter( Constants.CHNPARAMNOTMGR ) != null )
//      ManagerMode = false;

    // let determine the user's rights
    try{

      IPermission[] perms = channelStaticData.getAuthorizationPrincipal().getAllPermissions(
        Constants.PERMISSION_OWNERTOKEN, null, Constants.PERMISSION_OWNERTARGET );

      for( int i = 0; i < perms.length; i++ ) {

         if( perms[ i ].getActivity().equals( Constants.PERMISSION_MNGRRIGHT )
            && perms[ i ].getType().equals( IPermission.PERMISSION_TYPE_GRANT ))
          ManagerMode = true;

         if( perms[ i ].getActivity().equals( Constants.PERMISSION_PWDCHNGRIGHT )
            && perms[ i ].getType().equals( IPermission.PERMISSION_TYPE_DENY ))
          PwdChngMode = false;

      }// for
    }catch( AuthorizationException ae ){
        log.error(ae,ae);
    }

  }// setStaticData

  /**
   *  Receive channel runtime data from the portal.
   *  Satisfies implementation of IChannel Interface.
   *
   *  @param rd <b>ChannelRuntimeData</b> handle to channel runtime data
   */
  public void setRuntimeData(ChannelRuntimeData rd) {
    channelRuntimeData = rd;
  }// setRuntimeData

  /** Output channel content to the portal
   *  @param out a sax document handler
   */
  public void renderXML(ContentHandler out) throws PortalException {

    // first, be sure they are allowed to be here
    if( !ManagerMode && !PwdChngMode )
      throw new AuthorizationException(  MessageFormat.format(
        Constants.ERRMSG_NORIGHTS, new Object[]
          { (String)channelStaticData.getPerson().getAttribute( IPerson.USERNAME ) } ));

    try{

      String message_to_user_about_action = "";  // these always start blank
      Document doc = null;
      IPerson[] people = null;
      mode = Constants.MODEDISPLAY;

      // now, b4 we get going, there may have been an event to deal with<commit_msg>UP-1729 eliminated redundant IChannel-implementing method JavaDoc comments<commit_after>/* Copyright 2005 The JA-SIG Collaborative.  All rights reserved.
*  See license distributed with this file and
*  available online at http://www.uportal.org/license.html
*/
package org.jasig.portal.channels.cusermanager;

import java.util.Enumeration;
import java.text.MessageFormat;

import org.jasig.portal.IChannel;

import org.jasig.portal.security.IPerson;
import org.jasig.portal.security.IPermission;
import org.jasig.portal.security.provider.PersonImpl;
//import edu.cornell.uportal.channels.cusermanager.provider.PersonImpl;

import org.jasig.portal.ChannelStaticData;
import org.jasig.portal.ChannelRuntimeData;
import org.jasig.portal.ChannelRuntimeProperties;
import org.jasig.portal.PortalEvent;
import org.jasig.portal.PortalException;
import org.jasig.portal.IPermissible;
import org.jasig.portal.AuthorizationException;

import org.jasig.portal.utils.XSLT;
import org.jasig.portal.utils.DocumentFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import org.xml.sax.ContentHandler;

/**
 * @author <EMAIL>
 * @version $Revision$ $Date$
 */
public class CUserManager extends CUserManagerPermissions implements IChannel, IPermissible {

  private IDataHandler datasource;

  private String mode = Constants.MODEDISPLAY;

  private ChannelStaticData channelStaticData;
  private ChannelRuntimeData channelRuntimeData;

  private boolean ManagerMode = false;
  private boolean PwdChngMode = true;

  private PortalEvent lastEvent;

  /** for pwd chng mode, we want to cache the user's info because
   *  there will be many more of these than admin channels
   */
  private Document PersonalDocument = null;

  /**
   */
  public CUserManager() {
  }// CUserManager


  public ChannelRuntimeProperties getRuntimeProperties() {
    return new ChannelRuntimeProperties();
  }// getRuntimeProperties


  public void receiveEvent(PortalEvent ev) {

    this.lastEvent = ev;

  }// receiveEvent


  public void setStaticData(ChannelStaticData sd) {
    channelStaticData = sd;

// Ignore since 2.0 (2003.04.21)
//    if( CSD.getParameter( Constants.CHNPARAMNOTMGR ) != null )
//      ManagerMode = false;

    // let determine the user's rights
    try{

      IPermission[] perms = channelStaticData.getAuthorizationPrincipal().getAllPermissions(
        Constants.PERMISSION_OWNERTOKEN, null, Constants.PERMISSION_OWNERTARGET );

      for( int i = 0; i < perms.length; i++ ) {

         if( perms[ i ].getActivity().equals( Constants.PERMISSION_MNGRRIGHT )
            && perms[ i ].getType().equals( IPermission.PERMISSION_TYPE_GRANT ))
          ManagerMode = true;

         if( perms[ i ].getActivity().equals( Constants.PERMISSION_PWDCHNGRIGHT )
            && perms[ i ].getType().equals( IPermission.PERMISSION_TYPE_DENY ))
          PwdChngMode = false;

      }// for
    }catch( AuthorizationException ae ){
        log.error(ae,ae);
    }

  }// setStaticData


  public void setRuntimeData(ChannelRuntimeData rd) {
    channelRuntimeData = rd;
  }// setRuntimeData


  public void renderXML(ContentHandler out) throws PortalException {

    // first, be sure they are allowed to be here
    if( !ManagerMode && !PwdChngMode )
      throw new AuthorizationException(  MessageFormat.format(
        Constants.ERRMSG_NORIGHTS, new Object[]
          { (String)channelStaticData.getPerson().getAttribute( IPerson.USERNAME ) } ));

    try{

      String message_to_user_about_action = "";  // these always start blank
      Document doc = null;
      IPerson[] people = null;
      mode = Constants.MODEDISPLAY;

      // now, b4 we get going, there may have been an event to deal with
{'fraction_non_alphanumeric': 0.09599117322545053, 'fraction_numerical': 0.00490376363859262, 'mean_word_length': 3.5703081232493, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2495890', 'n_tokens_mistral': 2505, 'n_tokens_neox': 2424, 'n_words': 620}