Search in sources :

Example 1 with ExtensionPopupMenuItem

use of org.parosproxy.paros.extension.ExtensionPopupMenuItem in project zaproxy by zaproxy.

the class PopupUserMenuItemHolder method resetMenu.

private void resetMenu() {
    final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
    // Remove existing popup menu items
    if (visibleItself)
        this.removeAll();
    else {
        for (ExtensionPopupMenuItem menu : getSubmenuItems()) {
            mainPopupMenuItems.remove(menu);
        }
        subMenuItems.clear();
    }
    // Add a popup menu item for each existing users
    Session session = Model.getSingleton().getSession();
    List<Context> contexts = session.getContexts();
    for (Context context : contexts) {
        ContextUserAuthManager manager = extensionUserAuth.getContextUserAuthManager(context.getIndex());
        for (User user : manager.getUsers()) {
            ExtensionPopupMenuItem piicm;
            if (visibleItself) {
                piicm = getPopupUserMenu(context, user, this.getText());
                this.add(piicm);
            } else {
                piicm = getPopupUserMenu(context, user, this.parentName);
                piicm.setMenuIndex(this.getMenuIndex());
                mainPopupMenuItems.add(piicm);
                subMenuItems.add(piicm);
            }
        }
    }
}
Also used : Context(org.zaproxy.zap.model.Context) ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) User(org.zaproxy.zap.users.User) ContextUserAuthManager(org.zaproxy.zap.extension.users.ContextUserAuthManager) JMenuItem(javax.swing.JMenuItem) Session(org.parosproxy.paros.model.Session)

Example 2 with ExtensionPopupMenuItem

use of org.parosproxy.paros.extension.ExtensionPopupMenuItem in project zaproxy by zaproxy.

the class PopupMenuItemContextInclude method reCreateSubMenu.

protected void reCreateSubMenu() {
    final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
    for (ExtensionPopupMenuItem menu : subMenus) {
        mainPopupMenuItems.remove(menu);
    }
    subMenus.clear();
    Session session = Model.getSingleton().getSession();
    List<Context> contexts = session.getContexts();
    for (Context context : contexts) {
        ExtensionPopupMenuItem piicm = createPopupIncludeInContextMenu(context);
        piicm.setMenuIndex(this.getMenuIndex());
        mainPopupMenuItems.add(piicm);
        this.subMenus.add(piicm);
    }
    // Add the 'new context' menu
    ExtensionPopupMenuItem piicm = createPopupIncludeInContextMenu();
    mainPopupMenuItems.add(piicm);
    this.subMenus.add(piicm);
}
Also used : Context(org.zaproxy.zap.model.Context) ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) JMenuItem(javax.swing.JMenuItem) Session(org.parosproxy.paros.model.Session)

Example 3 with ExtensionPopupMenuItem

use of org.parosproxy.paros.extension.ExtensionPopupMenuItem in project zaproxy by zaproxy.

the class PopupContextMenuItemFactory method isEnableForComponent.

@Override
public boolean isEnableForComponent(Component invoker) {
    final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
    for (ExtensionPopupMenuItem menu : subMenus) {
        mainPopupMenuItems.remove(menu);
    }
    subMenus.clear();
    // Add the existing contexts
    Session session = Model.getSingleton().getSession();
    List<Context> contexts = session.getContexts();
    for (Context context : contexts) {
        ExtensionPopupMenuItem piicm = getContextMenu(context, this.parentMenu);
        piicm.setMenuIndex(this.getMenuIndex());
        mainPopupMenuItems.add(piicm);
        this.subMenus.add(piicm);
    }
    return false;
}
Also used : Context(org.zaproxy.zap.model.Context) ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) JMenuItem(javax.swing.JMenuItem) Session(org.parosproxy.paros.model.Session)

Example 4 with ExtensionPopupMenuItem

use of org.parosproxy.paros.extension.ExtensionPopupMenuItem in project zaproxy by zaproxy.

the class PopupContextMenuItemHolder method resetMenu.

private void resetMenu() {
    final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
    // Remove existing popup menu items
    if (visibleItself)
        this.removeAll();
    else {
        for (ExtensionPopupMenuItem menu : getSubmenuItems()) {
            mainPopupMenuItems.remove(menu);
        }
        subMenuItems.clear();
    }
    // Add a popup menu item for each existing context
    Session session = Model.getSingleton().getSession();
    List<Context> contexts = session.getContexts();
    for (Context context : contexts) {
        ExtensionPopupMenuItem piicm;
        if (visibleItself) {
            piicm = getPopupContextMenu(context, this.getText());
            this.add(piicm);
        } else {
            piicm = getPopupContextMenu(context, this.parentName);
            piicm.setMenuIndex(this.getMenuIndex());
            mainPopupMenuItems.add(piicm);
            subMenuItems.add(piicm);
        }
    }
}
Also used : PopupMenuItemContext(org.zaproxy.zap.view.popup.PopupMenuItemContext) Context(org.zaproxy.zap.model.Context) ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) JMenuItem(javax.swing.JMenuItem) Session(org.parosproxy.paros.model.Session)

Example 5 with ExtensionPopupMenuItem

use of org.parosproxy.paros.extension.ExtensionPopupMenuItem in project zaproxy by zaproxy.

the class PopupMenuItemSiteNodeContextMenuFactory method isButtonEnabledForSiteNode.

@Override
public boolean isButtonEnabledForSiteNode(SiteNode sn) {
    final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
    for (ExtensionPopupMenuItem menu : subMenus) {
        mainPopupMenuItems.remove(menu);
    }
    subMenus.clear();
    // Add the existing contexts
    Session session = Model.getSingleton().getSession();
    List<Context> contexts = session.getContexts();
    for (Context context : contexts) {
        ExtensionPopupMenuItem piicm = getContextMenu(context, this.parentMenu);
        piicm.setMenuIndex(this.getMenuIndex());
        mainPopupMenuItems.add(piicm);
        this.subMenus.add(piicm);
    }
    return false;
}
Also used : Context(org.zaproxy.zap.model.Context) ExtensionPopupMenuItem(org.parosproxy.paros.extension.ExtensionPopupMenuItem) JMenuItem(javax.swing.JMenuItem) Session(org.parosproxy.paros.model.Session)

Aggregations

JMenuItem (javax.swing.JMenuItem)8 ExtensionPopupMenuItem (org.parosproxy.paros.extension.ExtensionPopupMenuItem)8 Session (org.parosproxy.paros.model.Session)7 Context (org.zaproxy.zap.model.Context)7 Component (java.awt.Component)1 ExtensionPopupMenu (org.zaproxy.zap.extension.ExtensionPopupMenu)1 ContextUserAuthManager (org.zaproxy.zap.extension.users.ContextUserAuthManager)1 User (org.zaproxy.zap.users.User)1 ExtensionPopupMenuComponent (org.zaproxy.zap.view.popup.ExtensionPopupMenuComponent)1 PopupMenuItemContext (org.zaproxy.zap.view.popup.PopupMenuItemContext)1