You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sm...@apache.org on 2014/11/11 21:35:27 UTC
[17/27] directory-fortress-commander git commit: change package
structure and names, pom improvements, license
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/apache/directory/fortress/web/panel/UserListPanel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/web/panel/UserListPanel.java b/src/main/java/org/apache/directory/fortress/web/panel/UserListPanel.java
new file mode 100644
index 0000000..f41e353
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/web/panel/UserListPanel.java
@@ -0,0 +1,812 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.fortress.web.panel;
+
+import com.inmethod.grid.IGridColumn;
+import com.inmethod.grid.SizeUnit;
+import com.inmethod.grid.column.PropertyColumn;
+import com.inmethod.grid.treegrid.TreeGrid;
+import org.apache.log4j.Logger;
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.attributes.AjaxCallListener;
+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
+import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.FormComponentPanel;
+import org.apache.wicket.markup.html.form.Radio;
+import org.apache.wicket.markup.html.form.RadioGroup;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.model.Model;
+import org.apache.directory.fortress.web.GlobalIds;
+import org.apache.directory.fortress.web.GlobalUtils;
+import org.apache.directory.fortress.web.SaveModelEvent;
+import org.apache.directory.fortress.web.SecureIndicatingAjaxButton;
+import org.apache.directory.fortress.web.SecureIndicatingAjaxLink;
+import org.apache.directory.fortress.web.SelectModelEvent;
+import org.apache.directory.fortress.web.UserListModel;
+import org.apache.directory.fortress.web.UserPage;
+import org.apache.directory.fortress.core.rbac.FortEntity;
+import org.apache.directory.fortress.core.rbac.OrgUnit;
+import org.apache.directory.fortress.core.rbac.Permission;
+import org.apache.directory.fortress.core.rbac.User;
+import org.apache.directory.fortress.core.rbac.UserRole;
+import org.apache.directory.fortress.core.util.attr.VUtil;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Shawn McKinney
+ * @version $Rev$
+ */
+public class UserListPanel extends FormComponentPanel
+{
+ private static final Logger LOG = Logger.getLogger( UserListPanel.class.getName() );
+ private Form listForm;
+ private DefaultTreeModel treeModel;
+ private DefaultMutableTreeNode node;
+ private TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String> grid;
+ private DefaultMutableTreeNode rootNode;
+ private String selectedRadioButton;
+ private TextField f1Fld;
+ private TextField f2Fld;
+ private Label f1Lbl;
+ private Label f2Lbl;
+ private Label searchFieldsLbl;
+ private WebMarkupContainer userformsearchfields;
+ private WebMarkupContainer searchFields;
+ private RadioGroup radioGroup;
+ private static final String USERS = "U";
+ private static final String ROLES = "R";
+ private static final String ADMIN_ROLES = "A";
+ private static final String OUS = "O";
+ private static final String PERMS = "P";
+ private Permission permission;
+ private SearchFields searchData = new SearchFields();
+ private static String PERM_OBJ_LABEL = "Object Name";
+ private static String PERM_OP_LABEL = "Operation Name";
+ private static String USER_LABEL = "User ID";
+ private static String ROLE_LABEL = "Role Name";
+ private static String ADMIN_LABEL = "Admin Role Name";
+ private static String OU_LABEL = "Organization";
+ private String field1Label = USER_LABEL;
+ private String field2Label;
+ private String searchFieldsLabel = USER_SEARCH_LABEL;
+ private static String USER_SEARCH_LABEL = "Search By User";
+ private static String ROLE_SEARCH_LABEL = "Search By Role";
+ private static String ADMIN_SEARCH_LABEL = "Search By Admininstrative Role";
+ private static String OU_SEARCH_LABEL = "Search By User Organization";
+ private static String PERM_SEARCH_LABEL = "Search By Permission";
+
+ public UserListPanel( String id )
+ {
+ super( id );
+ UserListModel userListModel = new UserListModel( new User(), GlobalUtils.getRbacSession( this ) );
+ setDefaultModel( userListModel );
+ addGrid();
+ userformsearchfields = new WebMarkupContainer( "userformsearchfields" );
+ userformsearchfields.setOutputMarkupId( true );
+ listForm.add( userformsearchfields );
+ addRadioButtons();
+ addSearchFields();
+ addButtons();
+ }
+
+ private void addRadioButtons()
+ {
+ radioGroup = new RadioGroup( "searchOptions", new PropertyModel( this, "selectedRadioButton" ) );
+ AjaxFormComponentUpdatingBehavior ajaxRadioUpdater = new AjaxFormChoiceComponentUpdatingBehavior()
+ {
+ @Override
+ protected void onUpdate( final AjaxRequestTarget target )
+ {
+ processRadioButton( target );
+ }
+ };
+ radioGroup.add( ajaxRadioUpdater );
+ add( radioGroup );
+ Radio userRb = new Radio( "userRb", new Model( USERS ) );
+ radioGroup.add( userRb );
+ Radio roleRb = new Radio( "roleRb", new Model( ROLES ) );
+ radioGroup.add( roleRb );
+ Radio adminRoleRb = new Radio( "adminRoleRb", new Model( ADMIN_ROLES ) );
+ radioGroup.add( adminRoleRb );
+ Radio ouRb = new Radio( "ouRb", new Model( OUS ) );
+ radioGroup.add( ouRb );
+ Radio permRb = new Radio( "permRb", new Model( new String( PERMS ) ) );
+ radioGroup.add( permRb );
+ radioGroup.setOutputMarkupId( true );
+ radioGroup.setRenderBodyOnly( false );
+
+ userformsearchfields.add( radioGroup );
+ selectedRadioButton = USERS;
+
+ addRoleSearchModal( roleRb );
+ addAdminRoleSearchModal( adminRoleRb );
+ addOUSearchModal( ouRb );
+ addPermSearchModal( permRb );
+ }
+
+ private void addSearchFields()
+ {
+ searchFields = new WebMarkupContainer( "searchfields" );
+ searchFieldsLbl = new Label( "searchFieldslabel", new PropertyModel<String>( this, "searchFieldsLabel" ) );
+ searchFields.add( searchFieldsLbl );
+ f1Lbl = new Label( "field1label", new PropertyModel<String>( this, "field1Label" ) );
+ searchFields.add( f1Lbl );
+ f2Lbl = new Label( "field2label", new PropertyModel<String>( this, "field2Label" ) );
+ searchFields.add( f2Lbl );
+
+ f1Fld = new TextField( GlobalIds.FIELD_1, new PropertyModel<String>( this, "searchData.field1" ) );
+ f1Fld.setOutputMarkupId( true );
+ AjaxFormComponentUpdatingBehavior ajaxUpdater = new AjaxFormComponentUpdatingBehavior( GlobalIds.ONBLUR )
+ {
+ @Override
+ protected void onUpdate( final AjaxRequestTarget target )
+ {
+ target.add( f1Fld );
+ }
+ };
+ f1Fld.add( ajaxUpdater );
+ searchFields.add( f1Fld );
+
+ f2Fld = new TextField( GlobalIds.FIELD_2, new PropertyModel<String>( this, "searchData.field2" ) );
+ f2Fld.setOutputMarkupId( true );
+ ajaxUpdater = new AjaxFormComponentUpdatingBehavior( GlobalIds.ONBLUR )
+ {
+ @Override
+ protected void onUpdate( final AjaxRequestTarget target )
+ {
+ target.add( f2Fld );
+ }
+ };
+ f2Fld.add( ajaxUpdater );
+ f2Fld.setVisible( false );
+ searchFields.add( f2Fld );
+ searchFields.setOutputMarkupId( true );
+ userformsearchfields.add( searchFields );
+ }
+
+ private void addButtons()
+ {
+ userformsearchfields.add( new SecureIndicatingAjaxButton( GlobalIds.SEARCH, GlobalIds.REVIEW_MGR,
+ GlobalIds.FIND_USERS )
+ {
+ @Override
+ protected void onSubmit( AjaxRequestTarget target, Form form )
+ {
+ LOG.debug( ".search.onSubmit selected radio button: " + selectedRadioButton );
+ info( "Searching Users..." );
+ String searchVal = "";
+ if ( VUtil.isNotNullOrEmpty( searchData.getField1() ) )
+ {
+ searchVal = searchData.getField1();
+ }
+ if ( selectedRadioButton.equals( PERMS ) )
+ {
+ LOG.debug( ".onSubmit PERMS RB selected" );
+
+ Permission srchPerm = new Permission();
+ srchPerm.setObjName( searchData.getField1() );
+ srchPerm.setOpName( searchData.getField2() );
+ setDefaultModel( new UserListModel( srchPerm, GlobalUtils.getRbacSession( this ) ) );
+ }
+ else
+ {
+ User srchUser = new User();
+ if ( selectedRadioButton.equals( USERS ) )
+ {
+ LOG.debug( ".onSubmit USERS_PAGE RB selected" );
+ srchUser.setUserId( searchVal );
+ }
+ else if ( selectedRadioButton.equals( ROLES ) )
+ {
+ LOG.debug( ".onSubmit ROLES RB selected" );
+ srchUser.setRole( searchVal );
+ }
+ else if ( selectedRadioButton.equals( ADMIN_ROLES ) )
+ {
+ LOG.debug( ".onSubmit ADMIN ROLES RB selected" );
+ srchUser.setAdminRole( searchVal );
+ }
+ else if ( selectedRadioButton.equals( OUS ) )
+ {
+ LOG.debug( ".onSubmit OUS RB selected" );
+ srchUser.setOu( searchVal );
+ }
+ else if ( selectedRadioButton.equals( PERMS ) )
+ {
+ LOG.debug( ".onSubmit PERMS RB selected" );
+ }
+ setDefaultModel( new UserListModel( srchUser, GlobalUtils.getRbacSession( this ) ) );
+ }
+
+ treeModel.reload();
+ rootNode.removeAllChildren();
+ List<User> users = ( List<User> ) getDefaultModelObject();
+ if ( VUtil.isNotNullOrEmpty( users ) )
+ {
+ for ( User user : users )
+ {
+ rootNode.add( new DefaultMutableTreeNode( user ) );
+ }
+ info( "Search returned " + users.size() + " matching objects" );
+ }
+ else
+ {
+ info( "No matching objects found" );
+ }
+ target.add( grid );
+ }
+
+ @Override
+ public void onError( AjaxRequestTarget target, Form form )
+ {
+ LOG.warn( ".search.onError" );
+ target.add();
+ }
+ } );
+ userformsearchfields.add( new AjaxSubmitLink( GlobalIds.CLEAR )
+ {
+ @Override
+ protected void onSubmit( AjaxRequestTarget target, Form form )
+ {
+ setResponsePage( new UserPage() );
+ }
+
+ @Override
+ public void onError( AjaxRequestTarget target, Form form )
+ {
+ LOG.warn( "UserListPanel.clear.onError" );
+ }
+
+ @Override
+ protected void updateAjaxAttributes( AjaxRequestAttributes attributes )
+ {
+ super.updateAjaxAttributes( attributes );
+ AjaxCallListener ajaxCallListener = new AjaxCallListener()
+ {
+ @Override
+ public CharSequence getFailureHandler( Component component )
+ {
+ return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
+ }
+ };
+ attributes.getAjaxCallListeners().add( ajaxCallListener );
+ }
+ } );
+ }
+
+ private void addRoleSearchModal( Radio roleRb )
+ {
+ final ModalWindow rolesModalWindow;
+ userformsearchfields.add( rolesModalWindow = new ModalWindow( "rolesearchmodal" ) );
+ final RoleSearchModalPanel roleSearchModalPanel = new RoleSearchModalPanel( rolesModalWindow.getContentId(),
+ rolesModalWindow, false );
+ rolesModalWindow.setContent( roleSearchModalPanel );
+ rolesModalWindow.setWindowClosedCallback( new ModalWindow.WindowClosedCallback()
+ {
+ @Override
+ public void onClose( AjaxRequestTarget target )
+ {
+ UserRole roleConstraint = roleSearchModalPanel.getRoleSelection();
+ if ( roleConstraint != null )
+ {
+ LOG.debug( "modal selected:" + roleConstraint.getName() );
+ searchData.setField1( roleConstraint.getName() );
+ selectedRadioButton = ROLES;
+ enableRoleSearch();
+ target.add( searchFields );
+ target.add( radioGroup );
+ }
+ }
+ } );
+
+ roleRb.add( new SecureIndicatingAjaxLink( "roleAssignLinkLbl", GlobalIds.REVIEW_MGR, GlobalIds.FIND_ROLES )
+ {
+ public void onClick( AjaxRequestTarget target )
+ {
+ String msg = "clicked on roles search";
+ msg += "roleSelection: " + searchData.getField1();
+ roleSearchModalPanel.setRoleSearchVal( searchData.getField1() );
+ roleSearchModalPanel.setAdmin( false );
+ target.prependJavaScript( GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE );
+ rolesModalWindow.show( target );
+ }
+
+ @Override
+ protected void updateAjaxAttributes( AjaxRequestAttributes attributes )
+ {
+ super.updateAjaxAttributes( attributes );
+ AjaxCallListener ajaxCallListener = new AjaxCallListener()
+ {
+ @Override
+ public CharSequence getFailureHandler( Component component )
+ {
+ return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
+ }
+ };
+ attributes.getAjaxCallListeners().add( ajaxCallListener );
+ }
+ } );
+ rolesModalWindow.setTitle( "RBAC Role Search Modal" );
+ rolesModalWindow.setInitialWidth( 700 );
+ rolesModalWindow.setInitialHeight( 450 );
+ rolesModalWindow.setCookieName( "role-assign-modal" );
+ }
+
+ private void addAdminRoleSearchModal( Radio adminRoleRb )
+ {
+ final ModalWindow adminRolesModalWindow;
+ userformsearchfields.add( adminRolesModalWindow = new ModalWindow( "adminrolesearchmodal" ) );
+ final RoleSearchModalPanel adminRoleSearchModalPanel = new RoleSearchModalPanel( adminRolesModalWindow
+ .getContentId(), adminRolesModalWindow, true );
+ adminRolesModalWindow.setContent( adminRoleSearchModalPanel );
+ adminRolesModalWindow.setWindowClosedCallback( new ModalWindow.WindowClosedCallback()
+ {
+ @Override
+ public void onClose( AjaxRequestTarget target )
+ {
+ UserRole roleConstraint = adminRoleSearchModalPanel.getRoleSelection();
+ if ( roleConstraint != null )
+ {
+ searchData.setField1( roleConstraint.getName() );
+ selectedRadioButton = ADMIN_ROLES;
+ enableAdminSearch();
+ target.add( searchFields );
+ target.add( radioGroup );
+ }
+ }
+ } );
+
+ adminRoleRb.add( new SecureIndicatingAjaxLink( "adminRoleAssignLinkLbl", GlobalIds.DEL_REVIEW_MGR,
+ GlobalIds.FIND_ROLES )
+ {
+ public void onClick( AjaxRequestTarget target )
+ {
+ String msg = "clicked on admin roles search";
+ msg += "adminRoleSelection: " + searchData.getField1();
+ adminRoleSearchModalPanel.setRoleSearchVal( searchData.getField1() );
+ adminRoleSearchModalPanel.setAdmin( true );
+ LOG.debug( msg );
+ target.prependJavaScript( GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE );
+ adminRolesModalWindow.show( target );
+ }
+
+ @Override
+ protected void updateAjaxAttributes( AjaxRequestAttributes attributes )
+ {
+ super.updateAjaxAttributes( attributes );
+ AjaxCallListener ajaxCallListener = new AjaxCallListener()
+ {
+ @Override
+ public CharSequence getFailureHandler( Component component )
+ {
+ return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
+ }
+ };
+ attributes.getAjaxCallListeners().add( ajaxCallListener );
+ }
+ } );
+ adminRolesModalWindow.setTitle( "Admin Role Search Modal" );
+ adminRolesModalWindow.setInitialWidth( 700 );
+ adminRolesModalWindow.setInitialHeight( 450 );
+ adminRolesModalWindow.setCookieName( "role-assign-modal" );
+ }
+
+ private void addOUSearchModal( Radio ouRb )
+ {
+ final ModalWindow ousModalWindow;
+ userformsearchfields.add( ousModalWindow = new ModalWindow( "ousearchmodal" ) );
+ final OUSearchModalPanel ouSearchModalPanel = new OUSearchModalPanel( ousModalWindow.getContentId(),
+ ousModalWindow, true );
+ ousModalWindow.setContent( ouSearchModalPanel );
+ ousModalWindow.setWindowClosedCallback( new ModalWindow.WindowClosedCallback()
+ {
+ @Override
+ public void onClose( AjaxRequestTarget target )
+ {
+ OrgUnit ou = ouSearchModalPanel.getSelection();
+ if ( ou != null )
+ {
+ searchData.setField1( ou.getName() );
+ }
+ selectedRadioButton = OUS;
+ enableOuSearch();
+ target.add( searchFields );
+ target.add( radioGroup );
+ }
+ } );
+ ouRb.add( new SecureIndicatingAjaxLink( "ouAssignLinkLbl", GlobalIds.DEL_REVIEW_MGR, "searchOU" )
+ {
+ public void onClick( AjaxRequestTarget target )
+ {
+ String msg = "clicked on ou search";
+ msg += "ouSelection: " + searchData.getField1();
+ ouSearchModalPanel.setSearchVal( searchData.getField1() );
+ target.prependJavaScript( GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE );
+ ousModalWindow.show( target );
+ }
+
+ @Override
+ protected void updateAjaxAttributes( AjaxRequestAttributes attributes )
+ {
+ super.updateAjaxAttributes( attributes );
+ AjaxCallListener ajaxCallListener = new AjaxCallListener()
+ {
+ @Override
+ public CharSequence getFailureHandler( Component component )
+ {
+ return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
+ }
+ };
+ attributes.getAjaxCallListeners().add( ajaxCallListener );
+ }
+ } );
+
+ ousModalWindow.setTitle( "User Organizational Unit Search Modal" );
+ ousModalWindow.setInitialWidth( 450 );
+ ousModalWindow.setInitialHeight( 450 );
+ ousModalWindow.setCookieName( "userou-modal" );
+ }
+
+ @Override
+ public void onEvent( IEvent event )
+ {
+ if ( event.getPayload() instanceof SaveModelEvent )
+ {
+ SaveModelEvent modelEvent = ( SaveModelEvent ) event.getPayload();
+ switch ( modelEvent.getOperation() )
+ {
+ case ADD:
+ add( modelEvent.getEntity() );
+ break;
+ case UPDATE:
+ modelChanged();
+ break;
+ case DELETE:
+ prune();
+ break;
+ default:
+ LOG.error( "onEvent caught invalid operation" );
+ break;
+ }
+ AjaxRequestTarget target = ( ( SaveModelEvent ) event.getPayload() ).getAjaxRequestTarget();
+ //target.add(grid);
+ LOG.debug( ".onEvent AJAX - UserListPanel - SaveModelEvent: " + target.toString() );
+ }
+ }
+
+ private void addPermSearchModal( Radio permRb )
+ {
+ final ModalWindow permsModalWindow;
+ userformsearchfields.add( permsModalWindow = new ModalWindow( "permsearchmodal" ) );
+ final PermSearchModalPanel permSearchModalPanel = new PermSearchModalPanel( permsModalWindow.getContentId(),
+ permsModalWindow, false );
+ permsModalWindow.setContent( permSearchModalPanel );
+ permsModalWindow.setWindowClosedCallback( new ModalWindow.WindowClosedCallback()
+ {
+ @Override
+ public void onClose( AjaxRequestTarget target )
+ {
+ Permission permSelection = permSearchModalPanel.getSelection();
+ if ( permSelection != null )
+ {
+ searchData.setField1( permSelection.getObjName() );
+ searchData.setField2( permSelection.getOpName() );
+ }
+ selectedRadioButton = PERMS;
+ enablePermSearch();
+ target.add( searchFields );
+ target.add( radioGroup );
+ }
+ } );
+ permRb.add( new SecureIndicatingAjaxLink( "permLinkLbl", GlobalIds.REVIEW_MGR, GlobalIds.FIND_PERMISSIONS )
+ {
+ public void onClick( AjaxRequestTarget target )
+ {
+ String msg = "clicked on perms search";
+ msg += "permSelection: " + permission;
+ String objectSearchVal = "";
+ if ( VUtil.isNotNullOrEmpty( searchData.getField1() ) )
+ {
+ objectSearchVal = searchData.getField1();
+ }
+ permSearchModalPanel.setSearchVal( objectSearchVal );
+ LOG.debug( msg );
+ target.prependJavaScript( GlobalIds.WICKET_WINDOW_UNLOAD_CONFIRMATION_FALSE );
+ permsModalWindow.show( target );
+ }
+
+ @Override
+ protected void updateAjaxAttributes( AjaxRequestAttributes attributes )
+ {
+ super.updateAjaxAttributes( attributes );
+ AjaxCallListener ajaxCallListener = new AjaxCallListener()
+ {
+ @Override
+ public CharSequence getFailureHandler( Component component )
+ {
+ return GlobalIds.WINDOW_LOCATION_REPLACE_COMMANDER_HOME_HTML;
+ }
+ };
+ attributes.getAjaxCallListeners().add( ajaxCallListener );
+ }
+ } );
+ permsModalWindow.setTitle( "Admin Permission Search Modal" );
+ permsModalWindow.setInitialWidth( 650 );
+ permsModalWindow.setInitialHeight( 450 );
+ permsModalWindow.setCookieName( "perm-search-modal" );
+ }
+
+ private void removeSelectedItems( TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String> grid )
+ {
+ Collection<IModel<DefaultMutableTreeNode>> selected = grid.getSelectedItems();
+ for ( IModel<DefaultMutableTreeNode> model : selected )
+ {
+ DefaultMutableTreeNode node = model.getObject();
+ treeModel.removeNodeFromParent( node );
+ User user = ( User ) node.getUserObject();
+ LOG.debug( ".removeSelectedItems user node: " + user.getUserId() );
+ List<User> users = ( ( List<User> ) getDefaultModel().getObject() );
+ users.remove( user.getUserId() );
+ }
+ }
+
+ private DefaultTreeModel createTreeModel( List<User> users )
+ {
+ DefaultTreeModel model;
+ User rootUser = new User();
+ rootUser.setAddress( null );
+ rootNode = new DefaultMutableTreeNode( rootUser );
+ model = new DefaultTreeModel( rootNode );
+ if ( users == null )
+ {
+ LOG.debug( "no Users found" );
+ }
+ else
+ {
+ LOG.debug( ".createTreeModel Users found:" + users.size() );
+ for ( User user : users )
+ {
+ rootNode.add( new DefaultMutableTreeNode( user ) );
+ }
+ }
+ return model;
+ }
+
+ private void addGrid()
+ {
+ List<IGridColumn<DefaultTreeModel, DefaultMutableTreeNode,
+ String>> columns = new ArrayList<IGridColumn<DefaultTreeModel, DefaultMutableTreeNode, String>>();
+ columns.add( new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "UserId" ), "userObject.UserId" ) );
+/*
+ columns.add( new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "Name" ), "userObject.Name" ) );
+*/
+ PropertyColumn ou = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "User Organization" ), "userObject.Ou" );
+ ou.setInitialSize( 150 );
+ columns.add( ou );
+ columns.add( new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "Description" ), "userObject.Description" ) );
+ columns.add( new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "Address" ), "userObject.Address.Addresses" ) );
+ columns.add( new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "City" ), "userObject.Address.City" ) );
+ PropertyColumn state = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "State" ), "userObject.Address.State" );
+ state.setInitialSize( 50 );
+ columns.add( state );
+/*
+ PropertyColumn locked = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String, String>(
+ Model.of("Lock"), "userObject.locked");
+ locked.setInitialSize(40);
+ columns.add(locked);
+ PropertyColumn reset = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String, String>(
+ Model.of("Reset"), "userObject.reset");
+ reset.setInitialSize(40);
+ columns.add(reset);
+*/
+ PropertyColumn roles = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "RBAC Role Assignments" ), "userObject.Roles" );
+ roles.setInitialSize( 400 );
+ columns.add( roles );
+ PropertyColumn adminRoles = new PropertyColumn<DefaultTreeModel, DefaultMutableTreeNode, String,
+ String>( Model.of( "Admin Role Assignments" ), "userObject.AdminRoles" );
+ adminRoles.setInitialSize( 400 );
+ columns.add( adminRoles );
+
+ List<User> users = ( List<User> ) getDefaultModel().getObject();
+ treeModel = createTreeModel( users );
+ grid = new TreeGrid<DefaultTreeModel, DefaultMutableTreeNode, String>( "usertreegrid", treeModel, columns )
+ {
+ @Override
+ public void selectItem( IModel itemModel, boolean selected )
+ {
+ node = ( DefaultMutableTreeNode ) itemModel.getObject();
+ if ( !node.isRoot() )
+ {
+ User user = ( User ) node.getUserObject();
+ LOG.debug( "TreeGrid.addGrid.selectItem selected user =" + user.getUserId() );
+ if ( super.isItemSelected( itemModel ) )
+ {
+ LOG.debug( "TreeGrid.addGrid.selectItem item is selected" );
+ super.selectItem( itemModel, false );
+ }
+ else
+ {
+ super.selectItem( itemModel, true );
+ SelectModelEvent.send( getPage(), this, user );
+ }
+ }
+ }
+ };
+ grid.setContentHeight( 50, SizeUnit.EM );
+ grid.setAllowSelectMultiple( false );
+ grid.setClickRowToSelect( true );
+ grid.setClickRowToDeselect( false );
+ grid.setSelectToEdit( false );
+ // expand the root node
+ grid.getTreeState().expandNode( ( TreeNode ) treeModel.getRoot() );
+ this.listForm = new Form( "userlistform" );
+ this.listForm.add( grid );
+ add( this.listForm );
+ grid.setOutputMarkupId( true );
+ }
+
+ public void add( FortEntity entity )
+ {
+ if ( getDefaultModelObject() != null )
+ {
+ List<User> users = ( ( List<User> ) getDefaultModelObject() );
+ users.add( ( User ) entity );
+ LOG.debug( "UserListPanel.add tree depth: " + rootNode.getChildCount() );
+ treeModel.insertNodeInto( new DefaultMutableTreeNode( entity ), rootNode, rootNode.getChildCount() );
+ //treeModel.insertNodeInto(new DefaultMutableTreeNode(entity), rootNode, users.size());
+ }
+ }
+
+ public void prune()
+ {
+ removeSelectedItems( grid );
+ }
+
+ private void enableOuSearch()
+ {
+ f2Fld.setVisible( false );
+ f2Lbl.setVisible( false );
+ field1Label = OU_LABEL;
+ searchFieldsLabel = OU_SEARCH_LABEL;
+ }
+
+ private void enableAdminSearch()
+ {
+ f2Fld.setVisible( false );
+ f2Lbl.setVisible( false );
+ field1Label = ADMIN_LABEL;
+ searchFieldsLabel = ADMIN_SEARCH_LABEL;
+ }
+
+ private void enableRoleSearch()
+ {
+ f2Fld.setVisible( false );
+ f2Lbl.setVisible( false );
+ field1Label = ROLE_LABEL;
+ searchFieldsLabel = ROLE_SEARCH_LABEL;
+ }
+
+ private void enableUserSearch()
+ {
+ f2Fld.setVisible( false );
+ f2Lbl.setVisible( false );
+ field1Label = USER_LABEL;
+ searchFieldsLabel = USER_SEARCH_LABEL;
+ }
+
+ private void enablePermSearch()
+ {
+ f2Fld.setVisible( true );
+ f2Lbl.setVisible( true );
+ field1Label = PERM_OBJ_LABEL;
+ field2Label = PERM_OP_LABEL;
+ searchFieldsLabel = PERM_SEARCH_LABEL;
+ }
+
+ private void processRadioButton( AjaxRequestTarget target )
+ {
+ LOG.debug( "RADIO Button: " + selectedRadioButton );
+ if ( selectedRadioButton.equals( USERS ) )
+ {
+ enableUserSearch();
+ }
+ else if ( selectedRadioButton.equals( ROLES ) )
+ {
+ enableRoleSearch();
+ }
+ else if ( selectedRadioButton.equals( ADMIN_ROLES ) )
+ {
+ enableAdminSearch();
+ }
+ else if ( selectedRadioButton.equals( OUS ) )
+ {
+ enableOuSearch();
+ }
+ else if ( selectedRadioButton.equals( PERMS ) )
+ {
+ enablePermSearch();
+ }
+ searchData = new SearchFields();
+ target.add( searchFields );
+ }
+
+ class SearchFields implements Serializable
+ {
+ private String field1;
+ private String field2;
+ private String field3;
+
+ String getField1()
+ {
+ return field1;
+ }
+
+ void setField1( String field1 )
+ {
+ this.field1 = field1;
+ }
+
+ String getField2()
+ {
+ return field2;
+ }
+
+ void setField2( String field2 )
+ {
+ this.field2 = field2;
+ }
+
+ String getField3()
+ {
+ return field3;
+ }
+
+ void setField3( String field3 )
+ {
+ this.field3 = field3;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/apache/directory/fortress/web/panel/UserSearchModalPanel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/web/panel/UserSearchModalPanel.java b/src/main/java/org/apache/directory/fortress/web/panel/UserSearchModalPanel.java
new file mode 100644
index 0000000..514921e
--- /dev/null
+++ b/src/main/java/org/apache/directory/fortress/web/panel/UserSearchModalPanel.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.fortress.web.panel;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
+import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.PageableListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.apache.directory.fortress.web.GlobalIds;
+import org.apache.directory.fortress.web.GlobalUtils;
+import org.apache.directory.fortress.core.ReviewMgr;
+import org.apache.directory.fortress.core.rbac.User;
+
+/**
+ *
+ * @author Shawn McKinney
+ * @version $Rev$
+ */
+public class UserSearchModalPanel extends Panel
+{
+ @SpringBean
+ private ReviewMgr reviewMgr;
+ private static final Logger LOG = Logger.getLogger(UserSearchModalPanel.class.getName());
+ private ModalWindow window;
+ private User userSelection;
+ private String userSearchVal;
+
+ /**
+ * @param id
+ */
+ public UserSearchModalPanel( String id, ModalWindow window)
+ {
+ super( id );
+ // TODO: add later:
+ this.reviewMgr.setAdmin( GlobalUtils.getRbacSession( this ) );
+ this.window = window;
+ loadPanel();
+ }
+
+ public void loadPanel()
+ {
+ LoadableDetachableModel requests = getListViewModel();
+ PageableListView policyView = createListView( requests );
+ add( policyView );
+ add( new AjaxPagingNavigator( "usernavigator", policyView ) );
+ }
+
+ private PageableListView createListView( final LoadableDetachableModel requests )
+ {
+ final PageableListView listView = new PageableListView( "userdataview", requests, 10 )
+ {
+ @Override
+ protected void populateItem( final ListItem item )
+ {
+ final User modelObject = ( User ) item.getModelObject();
+ item.add( new AjaxLink<Void>( GlobalIds.SELECT )
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClick(AjaxRequestTarget target)
+ {
+ userSelection = modelObject;
+ window.close( target );
+ }
+ } );
+ item.add( new Label( GlobalIds.USER_ID, new PropertyModel( item.getModel(), GlobalIds.USER_ID ) ) );
+ item.add( new Label( GlobalIds.DESCRIPTION, new PropertyModel( item.getModel(), GlobalIds.DESCRIPTION ) ) );
+ item.add( new Label( GlobalIds.NAME, new PropertyModel( item.getModel(), GlobalIds.NAME ) ) );
+ item.add( new Label( GlobalIds.OU, new PropertyModel( item.getModel(), GlobalIds.OU ) ) );
+ item.add( new Label( GlobalIds.TITLE, new PropertyModel( item.getModel(), GlobalIds.TITLE ) ) );
+ item.add( new JpegImage( GlobalIds.JPEGPHOTO )
+ {
+ @Override
+ protected byte[] getPhoto()
+ {
+ byte[] photo;
+ photo = modelObject.getJpegPhoto();
+ return photo;
+ }
+ } );
+ }
+ };
+ return listView;
+ }
+
+ private LoadableDetachableModel getListViewModel()
+ {
+ final LoadableDetachableModel ret = new LoadableDetachableModel()
+ {
+ @Override
+ protected Object load()
+ {
+ List<User> users = null;
+ try
+ {
+ userSelection = null;
+ if(userSearchVal == null)
+ userSearchVal = "";
+ users = reviewMgr.findUsers( new User( userSearchVal ) );
+ }
+ catch ( org.apache.directory.fortress.core.SecurityException se )
+ {
+ String error = "loadPanel caught SecurityException=" + se;
+ LOG.error( error );
+ }
+ return users;
+ }
+ };
+ return ret;
+ }
+
+ public User getUserSelection()
+ {
+ return userSelection;
+ }
+
+ public void setSearchVal( String searchVal )
+ {
+ this.userSearchVal = searchVal;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/AjaxUpdateEvent.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/AjaxUpdateEvent.java b/src/main/java/org/openldap/commander/AjaxUpdateEvent.java
deleted file mode 100644
index 08a24ae..0000000
--- a/src/main/java/org/openldap/commander/AjaxUpdateEvent.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-
-import org.apache.wicket.ajax.AjaxRequestTarget;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- */
-public class AjaxUpdateEvent
-{
-
- private final AjaxRequestTarget target;
-
- public AjaxUpdateEvent(AjaxRequestTarget target)
- {
- this.target = target;
- }
-
- public AjaxRequestTarget getAjaxRequestTarget()
- {
- return target;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/ApplicationContext.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/ApplicationContext.java b/src/main/java/org/openldap/commander/ApplicationContext.java
deleted file mode 100644
index fce73dd..0000000
--- a/src/main/java/org/openldap/commander/ApplicationContext.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-package org.openldap.commander;
-
-
-import org.apache.wicket.Page;
-import org.apache.wicket.Session;
-import org.apache.wicket.core.request.handler.PageProvider;
-import org.apache.wicket.core.request.handler.RenderPageRequestHandler;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.Request;
-import org.apache.wicket.request.Response;
-import org.apache.wicket.request.cycle.AbstractRequestCycleListener;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- */
-public class ApplicationContext extends WebApplication
-{
- @Override
- public Session newSession( Request request, Response response )
- {
- return new RbacSession( request );
- }
-
- @Override
- public void init()
- {
- super.init();
- getComponentInstantiationListeners().add( new SpringComponentInjector( this ) );
-
- // Catch runtime exceptions this way:
- getRequestCycleListeners().add( new AbstractRequestCycleListener()
- {
- @Override
- public IRequestHandler onException( RequestCycle cycle, Exception e )
- {
- return new RenderPageRequestHandler( new PageProvider( new ErrorPage( e ) ) );
- }
- } );
- getMarkupSettings().setStripWicketTags( true );
- }
-
- public Class<? extends Page> getHomePage()
- {
- return LaunchPage.class;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/AuditAuthzListModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/AuditAuthzListModel.java b/src/main/java/org/openldap/commander/AuditAuthzListModel.java
deleted file mode 100644
index 04df5d2..0000000
--- a/src/main/java/org/openldap/commander/AuditAuthzListModel.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.injection.Injector;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-import org.openldap.fortress.AuditMgr;
-import org.openldap.fortress.ReviewMgr;
-import org.openldap.fortress.rbac.AuthZ;
-import org.openldap.fortress.rbac.Permission;
-import org.openldap.fortress.rbac.Session;
-import org.openldap.fortress.rbac.UserAudit;
-import org.openldap.fortress.util.attr.VUtil;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- * @param <T>
- */
-public class AuditAuthzListModel<T extends Serializable> extends Model
-{
- @SpringBean
- private AuditMgr auditMgr;
- @SpringBean
- private ReviewMgr reviewMgr;
- private static final Logger log = Logger.getLogger(AuditAuthzListModel.class.getName());
- private transient UserAudit userAudit;
- private transient List<AuthZ> authZs = null;
-
- /**
- * Default constructor
- */
- public AuditAuthzListModel( final Session session )
- {
- Injector.get().inject(this);
- this.auditMgr.setAdmin( session );
- }
-
- /**
- * User contains the search arguments.
- *
- * @param userAudit
- */
- public AuditAuthzListModel( UserAudit userAudit, final Session session )
- {
- Injector.get().inject(this);
- this.userAudit = userAudit;
- this.auditMgr.setAdmin( session );
- }
-
- /**
- * This data is bound for RoleListPanel
- *
- * @return T extends List<Role> roles data will be bound to panel data view component.
- */
- @Override
- public T getObject()
- {
- if (authZs != null)
- {
- log.debug(".getObject count: " + userAudit != null ? authZs.size() : "null");
- return (T) authZs;
- }
- // if caller did not set userId return an empty list:
- if (userAudit == null ||
- ( !VUtil.isNotNullOrEmpty( userAudit.getUserId() ) &&
- !VUtil.isNotNullOrEmpty( userAudit.getObjName() ) &&
- !VUtil.isNotNullOrEmpty( userAudit.getOpName() ) &&
- //!VUtil.isNotNullOrEmpty( userAudit.getDn() ) &&
- userAudit.getBeginDate() == null &&
- userAudit.getEndDate() == null
- )
- ||
- ( !VUtil.isNotNullOrEmpty( userAudit.getUserId() ) &&
- VUtil.isNotNullOrEmpty( userAudit.getObjName() ) &&
- !VUtil.isNotNullOrEmpty( userAudit.getOpName() ) &&
- userAudit.getBeginDate() == null &&
- userAudit.getEndDate() == null
- )
- )
-
- {
- log.debug(".getObject null");
- authZs = new ArrayList<AuthZ>();
- }
- else
- {
- // get the list of matching authorization records from fortress:
- //log.debug(".getObject authZ id: " + userAudit != null ? userAudit.getUserId() : "null");
- if(VUtil.isNotNullOrEmpty( userAudit.getObjName()) && VUtil.isNotNullOrEmpty( userAudit.getOpName()) && !VUtil.isNotNullOrEmpty( userAudit.getDn()))
- {
- Permission permission = getPermission( userAudit );
- userAudit.setDn( permission.getDn() );
- if(permission == null)
- {
- String warning = "Matching permission not found for object: " + userAudit.getObjName() + " operation: " + userAudit.getOpName();
- log.warn( warning );
- throw new RuntimeException( warning );
- }
- }
- authZs = getList(userAudit);
- userAudit.setDn( "" );
- }
- return (T) authZs;
- }
-
- @Override
- public void setObject(Object object)
- {
- log.debug(".setObject count: " + object != null ? ((List<AuthZ>)object).size() : "null");
- this.authZs = (List<AuthZ>) object;
- }
-
- @Override
- public void detach()
- {
- this.authZs = null;
- this.userAudit = null;
- }
-
- private List<AuthZ> getList(UserAudit userAudit)
- {
- List<AuthZ> authZList = null;
- try
- {
- authZList = auditMgr.getUserAuthZs( userAudit );
- }
- catch (org.openldap.fortress.SecurityException se)
- {
- String error = ".getList caught SecurityException=" + se;
- log.warn(error);
- }
- return authZList;
- }
-
- private Permission getPermission(UserAudit userAudit)
- {
- Permission permission = null;
- try
- {
- permission = reviewMgr.readPermission( new Permission ( userAudit.getObjName(), userAudit.getOpName(), userAudit.isAdmin()) );
- }
- catch (org.openldap.fortress.SecurityException se)
- {
- String error = ".getPermission caught SecurityException=" + se;
- log.warn(error);
- }
- return permission;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/AuditAuthzPage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/AuditAuthzPage.java b/src/main/java/org/openldap/commander/AuditAuthzPage.java
deleted file mode 100644
index cdf4f25..0000000
--- a/src/main/java/org/openldap/commander/AuditAuthzPage.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.openldap.commander.panel.AuditAuthzDetailPanel;
-import org.openldap.commander.panel.AuditAuthzListPanel;
-import org.openldap.commander.panel.Displayable;
-import org.openldap.commander.panel.InfoPanel;
-import org.openldap.commander.panel.NavPanel;
-import org.openldap.fortress.rbac.UserAudit;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- * Date: 8/6/13
- */
-public class AuditAuthzPage extends CommanderBasePage
-{
- boolean firstLoad = true;
-
- public AuditAuthzPage()
- {
- UserAudit userAudit = new UserAudit();
- init( userAudit );
- }
-
- public AuditAuthzPage(final UserAudit userAudit)
- {
- boolean firstLoad = false;
- init( userAudit );
- }
-
- private void init(final UserAudit userAudit)
- {
- add(new Label("pageHeader", "Audit Authorization Viewer"));
- WebMarkupContainer container = new WebMarkupContainer(GlobalIds.LAYOUT);
- FourWaySplitter splitter = new FourWaySplitter("60", "40");
- splitter.addBorderLayout(container);
-
- // Add the four necessary panels for Commander Page: 1. Nav,, 2. Info, 3. Detail, 4. List, .
- // Nav and Info are generic and work across all entities, the others are specific to this entity type.
-
- // 1. Nav Panel:
- NavPanel navPanel = new NavPanel(GlobalIds.NAVPANEL);
-
- // 2. Info Panel:
- InfoPanel infoPanel;
- if( firstLoad )
- {
- infoPanel = new InfoPanel(GlobalIds.INFOPANEL);
- }
- else
- {
- infoPanel = new InfoPanel(GlobalIds.INFOPANEL, "searching authorization records...");
- }
-
- container.add(infoPanel);
-
- // 3. Detail Panel:
- Displayable display = infoPanel.getDisplay();
- AuditAuthzDetailPanel authzDetail = new AuditAuthzDetailPanel("authzdetailpanel", display);
- container.add(authzDetail);
-
- container.add(navPanel);
-
- // 4. List Panel:
- container.add(new AjaxLazyLoadPanel("authzlistpanel")
- {
- @Override
- public Component getLazyLoadComponent(String id)
- {
- return new AuditAuthzListPanel( id, userAudit );
- }
- });
-
- this.add(container);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/AuditBindListModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/AuditBindListModel.java b/src/main/java/org/openldap/commander/AuditBindListModel.java
deleted file mode 100644
index d2156fa..0000000
--- a/src/main/java/org/openldap/commander/AuditBindListModel.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.injection.Injector;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-import org.openldap.fortress.AuditMgr;
-import org.openldap.fortress.rbac.Bind;
-import org.openldap.fortress.rbac.Session;
-import org.openldap.fortress.rbac.UserAudit;
-import org.openldap.fortress.util.attr.VUtil;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- * @param <T>
- */
-public class AuditBindListModel<T extends Serializable> extends Model
-{
- @SpringBean
- private AuditMgr auditMgr;
- private static final Logger log = Logger.getLogger(AuditBindListModel.class.getName());
- private transient UserAudit userAudit;
- private transient List<Bind> binds = null;
-
- /**
- * Default constructor
- */
- public AuditBindListModel( final Session session )
- {
- Injector.get().inject(this);
- this.auditMgr.setAdmin( session );
- }
-
- /**
- * User contains the search arguments.
- *
- * @param userAudit
- */
- public AuditBindListModel( UserAudit userAudit, final Session session )
- {
- Injector.get().inject(this);
- this.userAudit = userAudit;
- this.auditMgr.setAdmin( session );
- }
-
- /**
- * This data is bound for RoleListPanel
- *
- * @return T extends List<Role> roles data will be bound to panel data view component.
- */
- @Override
- public T getObject()
- {
- if (binds != null)
- {
- log.debug(".getObject count: " + userAudit != null ? binds.size() : "null");
- return (T) binds;
- }
- // if caller did not set userId return an empty list:
- if (userAudit == null ||
- ( !VUtil.isNotNullOrEmpty( userAudit.getUserId() ) &&
- userAudit.getBeginDate() == null &&
- userAudit.getEndDate() == null
- )
- )
- {
- log.debug(".getObject null");
- binds = new ArrayList<Bind>();
- }
- else
- {
- // get the list of matching bind records from fortress:
- binds = getList(userAudit);
- }
- return (T) binds;
- }
-
- @Override
- public void setObject(Object object)
- {
- log.debug(".setObject count: " + object != null ? ((List<Bind>)object).size() : "null");
- this.binds = (List<Bind>) object;
- }
-
- @Override
- public void detach()
- {
- this.binds = null;
- this.userAudit = null;
- }
-
- private List<Bind> getList(UserAudit userAudit)
- {
- List<Bind> bindList = null;
- try
- {
- bindList = auditMgr.searchBinds( userAudit );
- }
- catch (org.openldap.fortress.SecurityException se)
- {
- String error = ".getList caught SecurityException=" + se;
- log.warn(error);
- }
- return bindList;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/AuditBindPage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/AuditBindPage.java b/src/main/java/org/openldap/commander/AuditBindPage.java
deleted file mode 100644
index 0eafe92..0000000
--- a/src/main/java/org/openldap/commander/AuditBindPage.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.openldap.commander.panel.AuditBindDetailPanel;
-import org.openldap.commander.panel.AuditBindListPanel;
-import org.openldap.commander.panel.Displayable;
-import org.openldap.commander.panel.InfoPanel;
-import org.openldap.commander.panel.NavPanel;
-import org.openldap.fortress.rbac.UserAudit;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- * Date: 8/11/13
- */
-public class AuditBindPage extends CommanderBasePage
-{
- boolean firstLoad = true;
-
- public AuditBindPage()
- {
- UserAudit userAudit = new UserAudit();
- init( userAudit );
- }
-
- public AuditBindPage(final UserAudit userAudit)
- {
- boolean firstLoad = false;
- init( userAudit );
- }
-
- private void init(final UserAudit userAudit)
- {
- add(new Label(GlobalIds.PAGE_HEADER, "Audit Bind Viewer"));
- WebMarkupContainer container = new WebMarkupContainer(GlobalIds.LAYOUT);
- FourWaySplitter splitter = new FourWaySplitter("60", "40");
- splitter.addBorderLayout(container);
-
- // Add the four necessary panels for Commander Page: 1. Nav,, 2. Info, 3. Detail, 4. List, .
- // Nav and Info are generic and work across all entities, the others are specific to this entity type.
-
- // 1. Nav Panel:
- NavPanel navPanel = new NavPanel(GlobalIds.NAVPANEL);
-
- // 2. Info Panel:
- InfoPanel infoPanel;
- if( firstLoad )
- {
- infoPanel = new InfoPanel(GlobalIds.INFOPANEL);
- }
- else
- {
- infoPanel = new InfoPanel(GlobalIds.INFOPANEL, "searching authentication records...");
- }
-
- container.add(infoPanel);
-
- // 3. Detail Panel:
- Displayable display = infoPanel.getDisplay();
- AuditBindDetailPanel bindDetail = new AuditBindDetailPanel("binddetailpanel", display);
- container.add(bindDetail);
-
- container.add(navPanel);
-
- // 4. List Panel:
- container.add(new AjaxLazyLoadPanel("bindlistpanel")
- {
- @Override
- public Component getLazyLoadComponent(String id)
- {
- return new AuditBindListPanel( id, userAudit );
- }
- });
-
- this.add(container);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/AuditModListModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/AuditModListModel.java b/src/main/java/org/openldap/commander/AuditModListModel.java
deleted file mode 100644
index f17317e..0000000
--- a/src/main/java/org/openldap/commander/AuditModListModel.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.injection.Injector;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-import org.openldap.fortress.AuditMgr;
-import org.openldap.fortress.ReviewMgr;
-import org.openldap.fortress.rbac.AuthZ;
-import org.openldap.fortress.rbac.Mod;
-import org.openldap.fortress.rbac.Session;
-import org.openldap.fortress.rbac.User;
-import org.openldap.fortress.rbac.UserAudit;
-import org.openldap.fortress.util.attr.VUtil;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- * @param <T>
- */
-public class AuditModListModel<T extends Serializable> extends Model
-{
- @SpringBean
- private AuditMgr auditMgr;
- @SpringBean
- private ReviewMgr reviewMgr;
- private static final Logger log = Logger.getLogger(AuditModListModel.class.getName());
- private transient UserAudit userAudit;
- private transient List<Mod> mods = null;
-
- /**
- * Default constructor
- */
- public AuditModListModel( final Session session )
- {
- Injector.get().inject(this);
- this.auditMgr.setAdmin( session );
- }
-
- /**
- * User contains the search arguments.
- *
- * @param userAudit
- */
- public AuditModListModel( UserAudit userAudit, final Session session )
- {
- Injector.get().inject(this);
- this.userAudit = userAudit;
- this.auditMgr.setAdmin( session );
- }
-
- /**
- * This data is bound for RoleListPanel
- *
- * @return T extends List<Role> roles data will be bound to panel data view component.
- */
- @Override
- public T getObject()
- {
- if (mods != null)
- {
- log.debug(".getObject count: " + userAudit != null ? mods.size() : "null");
- return (T) mods;
- }
- // if caller did not set userId return an empty list:
- if (userAudit == null ||
- ( !VUtil.isNotNullOrEmpty( userAudit.getUserId() ) &&
- !VUtil.isNotNullOrEmpty( userAudit.getObjName() ) &&
- !VUtil.isNotNullOrEmpty( userAudit.getOpName() ) &&
- userAudit.getBeginDate() == null &&
- userAudit.getEndDate() == null
- )
- )
- {
- log.debug(".getObject null");
- mods = new ArrayList<Mod>();
- }
- else
- {
- // do we need to retrieve the internalUserId (which is what maps to admin modification record in slapd audit log?
- if(VUtil.isNotNullOrEmpty( userAudit.getUserId()) && !VUtil.isNotNullOrEmpty( userAudit.getInternalUserId()))
- {
- User user = getUser( userAudit );
- userAudit.setInternalUserId( user.getInternalId() );
- if(user == null)
- {
- String warning = "Matching user not found for userId: " + userAudit.getUserId();
- log.warn( warning );
- throw new RuntimeException( warning );
- }
- }
- mods = getList(userAudit);
- }
- return (T) mods;
- }
-
- @Override
- public void setObject(Object object)
- {
- log.debug(".setObject count: " + object != null ? ((List<AuthZ>)object).size() : "null");
- this.mods = (List<Mod>) object;
- }
-
- @Override
- public void detach()
- {
- this.mods = null;
- this.userAudit = null;
- }
-
- private List<Mod> getList(UserAudit userAudit)
- {
- List<Mod> modList = null;
- try
- {
- userAudit.setDn( "" );
- if(VUtil.isNotNullOrEmpty( userAudit.getObjName() ))
- {
- userAudit.setObjName( getTruncatedObjName( userAudit.getObjName() ) );
- }
- modList = auditMgr.searchAdminMods( userAudit );
- }
- catch (org.openldap.fortress.SecurityException se)
- {
- String error = ".getList caught SecurityException=" + se;
- log.warn(error);
- }
- return modList;
- }
-
- /**
- * Utility will parse a String containing objName.operationName and return the objName only.
- *
- * @param szObj contains raw data format.
- * @return String containing objName.
- */
- private String getTruncatedObjName(String szObj)
- {
- int indx = szObj.lastIndexOf('.');
- if(indx == -1)
- {
- return szObj;
- }
- return szObj.substring(indx + 1);
- }
-
- private User getUser(UserAudit userAudit)
- {
- User user = null;
- try
- {
- user = reviewMgr.readUser( new User ( userAudit.getUserId() ) );
- }
- catch (org.openldap.fortress.SecurityException se)
- {
- String error = ".getUser caught SecurityException=" + se;
- log.warn(error);
- }
- return user;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/AuditModPage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/AuditModPage.java b/src/main/java/org/openldap/commander/AuditModPage.java
deleted file mode 100644
index f6dfb6d..0000000
--- a/src/main/java/org/openldap/commander/AuditModPage.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-package org.openldap.commander;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.openldap.commander.panel.AuditModDetailPanel;
-import org.openldap.commander.panel.AuditModListPanel;
-import org.openldap.commander.panel.Displayable;
-import org.openldap.commander.panel.InfoPanel;
-import org.openldap.commander.panel.NavPanel;
-import org.openldap.fortress.rbac.UserAudit;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- * Date: 8/10/13
- */
-public class AuditModPage extends CommanderBasePage
-{
- boolean firstLoad = true;
-
- public AuditModPage()
- {
- UserAudit userAudit = new UserAudit();
- init( userAudit );
- }
-
- public AuditModPage(final UserAudit userAudit)
- {
- boolean firstLoad = false;
- init( userAudit );
- }
-
- private void init(final UserAudit userAudit)
- {
- add(new Label(GlobalIds.PAGE_HEADER, "Audit Modification Viewer"));
- WebMarkupContainer container = new WebMarkupContainer(GlobalIds.LAYOUT);
- FourWaySplitter splitter = new FourWaySplitter("55", "45");
- splitter.addBorderLayout(container);
-
- // Add the four necessary panels for Commander Page: 1. Nav,, 2. Info, 3. Detail, 4. List, .
- // Nav and Info are generic and work across all entities, the others are specific to this entity type.
-
- // 1. Nav Panel:
- NavPanel navPanel = new NavPanel( GlobalIds.NAVPANEL );
-
- // 2. Info Panel:
- InfoPanel infoPanel;
- if( firstLoad )
- {
- infoPanel = new InfoPanel(GlobalIds.INFOPANEL);
- }
- else
- {
- infoPanel = new InfoPanel(GlobalIds.INFOPANEL, "searching modification records...");
- }
-
- container.add(infoPanel);
-
- // 3. Detail Panel:
- Displayable display = infoPanel.getDisplay();
- AuditModDetailPanel modDetail = new AuditModDetailPanel("moddetailpanel", display);
- container.add(modDetail);
-
- container.add(navPanel);
-
- // 4. List Panel:
- container.add(new AjaxLazyLoadPanel("modlistpanel")
- {
- @Override
- public Component getLazyLoadComponent(String id)
- {
- //return new AuditAuthzListPanel(id);
- return new AuditModListPanel( id, userAudit );
- }
- });
-
- this.add(container);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/Authorizable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/Authorizable.java b/src/main/java/org/openldap/commander/Authorizable.java
deleted file mode 100644
index a902ff1..0000000
--- a/src/main/java/org/openldap/commander/Authorizable.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-package org.openldap.commander;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * ...
- *
- * @author Shawn McKinney
- * @version $Rev$
- */
-
-@Retention( RetentionPolicy.RUNTIME)
-@Target( ElementType.TYPE)
-@Inherited
-public @interface Authorizable
-{
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/CommanderBasePage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/CommanderBasePage.java b/src/main/java/org/openldap/commander/CommanderBasePage.java
deleted file mode 100644
index 47d43f3..0000000
--- a/src/main/java/org/openldap/commander/CommanderBasePage.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.spring.injection.annot.SpringBean;
-import org.openldap.fortress.*;
-import org.openldap.fortress.rbac.Session;
-import org.openldap.fortress.rbac.Permission;
-import org.openldap.fortress.rbac.User;
-
-import javax.servlet.http.HttpServletRequest;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.security.Principal;
-import java.util.List;
-
-/**
- * Base class for Commander Web. This class initializes Fortress RBAC context and so contains a synchronized block.
- *
- * @author Shawn McKinney
- * @version $Rev$
- */
-public abstract class CommanderBasePage extends WebPage
-{
- @SpringBean
- private AccessMgr accessMgr;
- @SpringBean
- private DelAccessMgr delAccessMgr;
- private static final String CLS_NM = CommanderBasePage.class.getName();
- private static final Logger LOG = Logger.getLogger( CLS_NM );
-
- public CommanderBasePage()
- {
- SecureBookmarkablePageLink usersLink = new SecureBookmarkablePageLink( GlobalIds.USERS_PAGE, UserPage.class,
- GlobalIds.ROLE_USERS );
- add( usersLink );
- PageParameters parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.RBAC_TYPE );
- SecureBookmarkablePageLink rolesLink = new SecureBookmarkablePageLink( GlobalIds.ROLES_PAGE, RolePage.class,
- parameters, GlobalIds.ROLE_ROLES );
- add( rolesLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.ADMIN_TYPE );
- SecureBookmarkablePageLink admrolesLink = new SecureBookmarkablePageLink( GlobalIds.ADMROLES_PAGE,
- RoleAdminPage.class, parameters, GlobalIds.ROLE_ADMINROLES );
- add( admrolesLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.RBAC_TYPE );
- SecureBookmarkablePageLink objectsLink = new SecureBookmarkablePageLink( GlobalIds.POBJS_PAGE,
- ObjectPage.class, parameters, GlobalIds.ROLE_PERMOBJS );
- add( objectsLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.ADMIN_TYPE );
- SecureBookmarkablePageLink admobjsLink = new SecureBookmarkablePageLink( GlobalIds.ADMPOBJS_PAGE,
- ObjectAdminPage.class, parameters, GlobalIds.ROLE_ADMINOBJS );
- add( admobjsLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.RBAC_TYPE );
- SecureBookmarkablePageLink permsLink = new SecureBookmarkablePageLink( GlobalIds.PERMS_PAGE, PermPage.class,
- parameters, GlobalIds.ROLE_PERMS );
- add( permsLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.ADMIN_TYPE );
- SecureBookmarkablePageLink admpermsLink = new SecureBookmarkablePageLink( GlobalIds.ADMPERMS_PAGE,
- PermAdminPage.class, parameters, GlobalIds.ROLE_ADMINPERMS );
- add( admpermsLink );
- SecureBookmarkablePageLink policiesLink = new SecureBookmarkablePageLink( GlobalIds.PWPOLICIES_PAGE,
- PwPolicyPage.class, GlobalIds.ROLE_POLICIES );
- add( policiesLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.SSD );
- SecureBookmarkablePageLink ssdsLink = new SecureBookmarkablePageLink( GlobalIds.SSDS_PAGE,
- SdStaticPage.class, parameters, GlobalIds.ROLE_SSDS );
- add( ssdsLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.DSD );
- SecureBookmarkablePageLink dsdsLink = new SecureBookmarkablePageLink( GlobalIds.DSDS_PAGE,
- SdDynamicPage.class, parameters, GlobalIds.ROLE_DSDS );
- add( dsdsLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, GlobalIds.USEROUS );
- SecureBookmarkablePageLink userouLink = new SecureBookmarkablePageLink( GlobalIds.USEROUS_PAGE,
- OuUserPage.class, parameters, GlobalIds.ROLE_USEROUS );
- add( userouLink );
- parameters = new PageParameters();
- //parameters.set( GlobalIds.PAGE_TYPE, "PERMOUS" );
- SecureBookmarkablePageLink permouLink = new SecureBookmarkablePageLink( GlobalIds.PERMOUS_PAGE,
- OuPermPage.class, parameters, GlobalIds.ROLE_PERMOUS );
- add( permouLink );
-
- add( new SecureBookmarkablePageLink( GlobalIds.GROUP_PAGE, GroupPage.class,
- GlobalIds.ROLE_GROUPS ) );
-
- add( new SecureBookmarkablePageLink( GlobalIds.AUDIT_BINDS_PAGE, AuditBindPage.class,
- GlobalIds.ROLE_AUDIT_BINDS ) );
-
- add( new SecureBookmarkablePageLink( GlobalIds.AUDIT_AUTHZS_PAGE, AuditAuthzPage.class,
- GlobalIds.ROLE_AUDIT_AUTHZS ) );
-
- add( new SecureBookmarkablePageLink( GlobalIds.AUDIT_MODS_PAGE, AuditModPage.class,
- GlobalIds.ROLE_AUDIT_MODS ) );
-
- add( new Label( "footer", "Copyright (c) 1998-2014, The OpenLDAP Foundation. All Rights Reserved." ) );
-
- final Link actionLink = new Link( "logout" )
- {
- @Override
- public void onClick()
- {
- HttpServletRequest servletReq = ( HttpServletRequest ) getRequest().getContainerRequest();
- servletReq.getSession().invalidate();
- getSession().invalidate();
- setResponsePage( LaunchPage.class );
- }
- };
- add( actionLink );
- HttpServletRequest servletReq = ( HttpServletRequest ) getRequest().getContainerRequest();
-
- // RBAC Security Processing:
- Principal principal = servletReq.getUserPrincipal();
- // Is this a Java EE secured page && has the User successfully authenticated already?
- boolean isSecured = principal != null;
- if( isSecured && !isLoggedIn( ) )
- {
- String szPrincipal = principal.toString();
- // Pull the RBAC session from the realm and assert into the Web app's session:
- Session realmSession = GlobalUtils.deserialize(szPrincipal, Session.class);
-
- // If this is null, app in container that cannot share rbac session with app, Must now create session manually:
- if(realmSession == null)
- {
- realmSession = GlobalUtils.createRbacSession( accessMgr, principal.getName() );
- }
- if(realmSession != null)
- {
- synchronized ( ( RbacSession ) RbacSession.get() )
- {
- GlobalUtils.loadPermissionsIntoSession( delAccessMgr, realmSession );
- }
- }
- // give up
- else
- {
- throw new RuntimeException( "cannot create RBAC session for user: " + principal.getName() );
- }
- }
- }
-
- private boolean isLoggedIn( )
- {
- boolean isLoggedIn = false;
- if ( GlobalUtils.getRbacSession( this ) != null )
- {
- isLoggedIn = true;
- }
- return isLoggedIn;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/CommanderRequestCycleListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/CommanderRequestCycleListener.java b/src/main/java/org/openldap/commander/CommanderRequestCycleListener.java
deleted file mode 100644
index 7a86ccb..0000000
--- a/src/main/java/org/openldap/commander/CommanderRequestCycleListener.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.Page;
-import org.apache.wicket.WicketRuntimeException;
-import org.apache.wicket.core.request.handler.ComponentRenderingRequestHandler;
-import org.apache.wicket.markup.html.pages.ExceptionErrorPage;
-import org.apache.wicket.model.StringResourceModel;
-import org.apache.wicket.protocol.http.PageExpiredException;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.cycle.AbstractRequestCycleListener;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-/**
- * @author Shawn McKinney
- * @version $Rev$
- */
-@Deprecated
-public class CommanderRequestCycleListener extends AbstractRequestCycleListener
-{
- private static final Logger LOG = Logger.getLogger( CommanderRequestCycleListener.class.getName() );
-
- @Override
- public IRequestHandler onException( final RequestCycle cycle, final Exception e )
- {
- final Page errorPage;
- PageParameters errorParameters = new PageParameters();
- errorParameters.add( "title", "System Exception Occurred" );
- String error = "CommanderExceptionHandler caught ";
- if ( e instanceof PageExpiredException )
- {
- error += "PageExpiredException=" + e;
- errorParameters.add( "message", new StringResourceModel( "pageExpiredException", null ).getString() );
- errorPage = new ErrorPage( errorParameters );
- }
- else if ( e instanceof java.lang.RuntimeException )
- {
- error += "RuntimeException=" + e;
- errorParameters.add( "message", "Runtime Exception" );
- errorPage = new ErrorPage( errorParameters );
- }
- else if ( e instanceof WicketRuntimeException )
- {
- error += "PageExpiredException=" + e;
- errorParameters.add( "message", "Wicket Runtime Exception" );
- errorPage = new ErrorPage( errorParameters );
- }
- else
- {
- error += "UnknownException=" + e;
- errorParameters.add( "title", "Unknown Exception Occurred" );
- // Standard wicket error page:
- errorPage = new ExceptionErrorPage( e, null );
- }
- LOG.error( error );
- return new ComponentRenderingRequestHandler( errorPage );
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-fortress-commander/blob/547b9ccd/src/main/java/org/openldap/commander/ContextMenuPage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/openldap/commander/ContextMenuPage.java b/src/main/java/org/openldap/commander/ContextMenuPage.java
deleted file mode 100644
index c550bf4..0000000
--- a/src/main/java/org/openldap/commander/ContextMenuPage.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * This work is part of OpenLDAP Software <http://www.openldap.org/>.
- *
- * Copyright 1998-2014 The OpenLDAP Foundation.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted only as authorized by the OpenLDAP
- * Public License.
- *
- * A copy of this license is available in the file LICENSE in the
- * top-level directory of the distribution or, alternatively, at
- * <http://www.OpenLDAP.org/license.html>.
- */
-
-package org.openldap.commander;
-
-
-import com.googlecode.wicket.jquery.ui.JQueryIcon;
-import com.googlecode.wicket.jquery.ui.widget.menu.MenuItem;
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.markup.html.basic.Label;
-
-import com.googlecode.wicket.jquery.ui.widget.menu.ContextMenu;
-import com.googlecode.wicket.jquery.ui.widget.menu.ContextMenuBehavior;
-import com.googlecode.wicket.jquery.ui.widget.menu.IMenuItem;
-import org.apache.wicket.model.Model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- *
- * @author Kevin McKinney
- * @version $Rev$
- */
-public class ContextMenuPage extends CommanderBasePage
-{
- private static final long serialVersionUID = 1L;
-
- public ContextMenuPage()
- {
- // Menu //
- final ContextMenu menu = new ContextMenu( "menu", newMenuList() )
- {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onContextMenu( AjaxRequestTarget target, Component component )
- {
- //the menu-item list can be modified here
- //this.getItemList().add(new MenuItem("my new item"));
- }
-
- @Override
- public void onClick( AjaxRequestTarget target, IMenuItem item )
- {
- this.debug( "Clicked " + item.getTitle().getObject() );
-
- target.add( this );
- //target.add(feedback);
- }
- };
-
- this.add( menu );
-
- // Labels //
- final Label label1 = new Label( "label1", "my label 1" );
- label1.add( new ContextMenuBehavior( menu ) );
- this.add( label1 );
-
- final Label label2 = new Label( "label2", "my label 2" );
- label2.add( new ContextMenuBehavior( menu ) );
- this.add( label2 );
- }
-
- private List<IMenuItem> newMenuList()
- {
- List<IMenuItem> list = new ArrayList<IMenuItem>();
-
- list.add( new MenuItem( "Item with icon", JQueryIcon.FLAG ) );
- list.add( new MenuItem( "Change the title" )
- {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick( AjaxRequestTarget target )
- {
- this.setTitle( Model.of( "Title changed!" ) );
- }
- } );
- list.add( new MenuItem( "Another menu item" ) );
- list.add( new MenuItem( "Menu item, with sub-menu", JQueryIcon.BOOKMARK,
- this.newSubMenuList() ) ); // css-class are also allowed
- list.add( new MenuItem( "Desactivate me" )
- {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void onClick( AjaxRequestTarget target )
- {
- this.setEnabled( false );
- }
- } );
-
- return list;
- }
-
- private List<IMenuItem> newSubMenuList()
- {
- List<IMenuItem> list = new ArrayList<IMenuItem>();
-
- list.add( new MenuItem( "Sub-menu #1" ) );
- list.add( new MenuItem( "Sub-menu #2" ) );
- list.add( new MenuItem( "Sub-menu #3" ) );
-
- return list;
- }
-}