use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class PopupMenuItemContextDataDrivenNode method performAction.
@Override
public void performAction(SiteNode sn) {
Session session = Model.getSingleton().getSession();
SessionDialog sessionDialog = View.getSingleton().getSessionDialog();
sessionDialog.recreateUISharedContexts(session);
Context uiSharedContext = sessionDialog.getUISharedContext(context.getId());
// We want to form a regex expression like:
// https://www.example.com/(aa/bb/cc/)(.+?)(/.*)
StringBuilder sb = new StringBuilder();
SiteNode parent = sn.getParent();
while (!parent.getParent().isRoot()) {
sb.insert(0, "/");
if (parent.isDataDriven()) {
// Don't want these in their own regex group
sb.insert(0, ".+?");
} else {
sb.insert(0, parent.getCleanNodeName());
}
parent = parent.getParent();
}
sb.insert(0, "/(");
sb.insert(0, parent.getCleanNodeName());
sb.append(")(.+?)(/.*)");
Pattern p = Pattern.compile(sb.toString());
uiSharedContext.addDataDrivenNodes(new StructuralNodeModifier(StructuralNodeModifier.Type.DataDrivenNode, p, uiSharedContext.getDefaultDDNName()));
// Show the session dialog without recreating UI Shared contexts
View.getSingleton().showSessionDialog(session, ContextStructurePanel.getPanelName(context.getId()), false);
}
use of org.zaproxy.zap.model.Context 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);
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class AbstractContextSelectToolbarStatusPanel method getContextSelectComboBox.
/**
* Gets the Context select combo box.
*
* @return the context select combo box
*/
protected ContextSelectComboBox getContextSelectComboBox() {
if (contextSelectBox == null) {
contextSelectBox = new ContextSelectComboBox();
contextSelectBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
contextSelected((Context) contextSelectBox.getSelectedItem());
}
});
}
return contextSelectBox;
}
use of org.zaproxy.zap.model.Context 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.getId());
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);
}
}
}
}
use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.
the class UsersAPI method handleApiView.
@Override
public ApiResponse handleApiView(String name, JSONObject params) throws ApiException {
log.debug("handleApiView " + name + " " + params.toString());
switch(name) {
case VIEW_USERS_LIST:
ApiResponseList usersListResponse = new ApiResponseList(name);
// Get the users
List<User> users;
if (hasContextId(params))
users = extension.getContextUserAuthManager(getContextId(params)).getUsers();
else {
users = new ArrayList<>();
for (Context c : Model.getSingleton().getSession().getContexts()) users.addAll(extension.getContextUserAuthManager(c.getId()).getUsers());
}
// Prepare the response
for (User user : users) usersListResponse.addItem(buildResponseFromUser(user));
return usersListResponse;
case VIEW_GET_USER_BY_ID:
return buildResponseFromUser(getUser(params));
case VIEW_GET_AUTH_CREDENTIALS:
return getUser(params).getAuthenticationCredentials().getApiResponseRepresentation();
case VIEW_GET_AUTH_CREDENTIALS_CONFIG_PARAMETERS:
AuthenticationMethodType type = ApiUtils.getContextByParamId(params, PARAM_CONTEXT_ID).getAuthenticationMethod().getType();
ApiDynamicActionImplementor a = loadedAuthenticationMethodActions.get(type.getUniqueIdentifier());
return a.buildParamsDescription();
case VIEW_GET_AUTH_STATE:
return buildResponseFromAuthState(getUser(params).getAuthenticationState());
case VIEW_GET_AUTH_SESSION:
return buildResponseFromAuthSession(getUser(params).getAuthenticatedSession());
default:
throw new ApiException(ApiException.Type.BAD_VIEW);
}
}
Aggregations