Search in sources :

Example 56 with Context

use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.

the class PopupMenuItemContextDataDriven method reCreateSubMenu.

protected void reCreateSubMenu(SiteNode sn) {
    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) {
        if (context.isIncluded(sn)) {
            ExtensionPopupMenuItem piicm = createPopupDataDrivenNodeMenu(context);
            piicm.setMenuIndex(this.getMenuIndex());
            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 57 with Context

use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.

the class PopupMenuItemContextExclude 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 = createPopupExcludeFromContextMenu(context);
        piicm.setMenuIndex(this.getMenuIndex());
        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 58 with Context

use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.

the class SessionDialog method recreateUISharedContexts.

/**
	 * Reset the UI shared Context copies. The effect is that previous copies are discarded and new
	 * copies are created.
	 * 
	 * @param session the session
	 */
public void recreateUISharedContexts(Session session) {
    uiContexts.clear();
    for (Context context : session.getContexts()) {
        Context uiContext = context.duplicate();
        uiContexts.put(context.getIndex(), uiContext);
    }
}
Also used : Context(org.zaproxy.zap.model.Context)

Example 59 with Context

use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.

the class ForcedUserAPI method handleApiView.

@Override
public ApiResponse handleApiView(String name, JSONObject params) throws ApiException {
    log.debug("handleApiView " + name + " " + params.toString());
    switch(name) {
        case VIEW_GET_FORCED_USER:
            Context context = ApiUtils.getContextByParamId(params, PARAM_CONTEXT_ID);
            User forcedUser = extension.getForcedUser(context.getIndex());
            if (forcedUser != null)
                return new ApiResponseElement("forcedUserId", Integer.toString(forcedUser.getId()));
            else
                return new ApiResponseElement("forcedUserId", "");
        case VIEW_IS_FORCED_USER_MODE_ENABLED:
            return new ApiResponseElement("forcedModeEnabled", Boolean.toString(extension.isForcedUserModeEnabled()));
        default:
            throw new ApiException(Type.BAD_VIEW);
    }
}
Also used : Context(org.zaproxy.zap.model.Context) User(org.zaproxy.zap.users.User) ApiResponseElement(org.zaproxy.zap.extension.api.ApiResponseElement) ApiException(org.zaproxy.zap.extension.api.ApiException)

Aggregations

Context (org.zaproxy.zap.model.Context)59 ApiException (org.zaproxy.zap.extension.api.ApiException)19 Session (org.parosproxy.paros.model.Session)14 User (org.zaproxy.zap.users.User)14 JSONObject (net.sf.json.JSONObject)12 ApiDynamicActionImplementor (org.zaproxy.zap.extension.api.ApiDynamicActionImplementor)11 RecordContext (org.parosproxy.paros.db.RecordContext)9 ArrayList (java.util.ArrayList)8 DatabaseException (org.parosproxy.paros.db.DatabaseException)8 JMenuItem (javax.swing.JMenuItem)7 ConfigurationException (org.apache.commons.configuration.ConfigurationException)7 ExtensionPopupMenuItem (org.parosproxy.paros.extension.ExtensionPopupMenuItem)7 ApiResponseElement (org.zaproxy.zap.extension.api.ApiResponseElement)6 ExtensionUserManagement (org.zaproxy.zap.extension.users.ExtensionUserManagement)6 JSONException (net.sf.json.JSONException)4 URIException (org.apache.commons.httpclient.URIException)4 SiteNode (org.parosproxy.paros.model.SiteNode)4 SessionDialog (org.parosproxy.paros.view.SessionDialog)4 Tech (org.zaproxy.zap.model.Tech)4 IOException (java.io.IOException)3