Search in sources :

Example 21 with Context

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

the class SpiderDialog method setUsers.

private void setUsers() {
    Context context = this.getSelectedContext();
    List<String> userNames = new ArrayList<>();
    if (context != null) {
        List<User> users = this.extUserMgmt.getContextUserAuthManager(context.getId()).getUsers();
        // The default should always be 'not specified'
        userNames.add("");
        for (User user : users) {
            userNames.add(user.getName());
        }
    }
    this.setComboFields(FIELD_USER, userNames, "");
    // Theres always 1..
    this.getField(FIELD_USER).setEnabled(userNames.size() > 1);
}
Also used : Context(org.zaproxy.zap.model.Context) User(org.zaproxy.zap.users.User) ArrayList(java.util.ArrayList)

Example 22 with Context

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

the class SpiderDialog method getSelectedUser.

private User getSelectedUser() {
    Context context = this.getSelectedContext();
    if (context != null) {
        String userName = this.getStringValue(FIELD_USER);
        List<User> users = this.extUserMgmt.getContextUserAuthManager(context.getId()).getUsers();
        for (User user : users) {
            if (userName.equals(user.getName())) {
                return user;
            }
        }
    }
    return null;
}
Also used : Context(org.zaproxy.zap.model.Context) User(org.zaproxy.zap.users.User)

Example 23 with Context

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

the class ContextStructurePanel method saveContextData.

@Override
public void saveContextData(Session session) throws Exception {
    Context context = session.getContext(getContextId());
    saveToContext(context, true);
}
Also used : Context(org.zaproxy.zap.model.Context)

Example 24 with Context

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

the class DeleteContextAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    List<Context> contexts = getContexts();
    if (contexts.isEmpty()) {
        return;
    }
    String contextList = contexts.stream().map(Context::getName).collect(Collectors.joining("\n"));
    if (View.getSingleton().showConfirmDialog(contexts.size() > 1 ? Constant.messages.getString("context.delete.warning.multiple", contextList) : Constant.messages.getString("context.delete.warning")) == JOptionPane.OK_OPTION) {
        for (Context context : contexts) {
            Model.getSingleton().getSession().deleteContext(context);
        }
    }
}
Also used : Context(org.zaproxy.zap.model.Context)

Example 25 with Context

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

the class ContextExcludePanel method saveContextData.

@Override
public void saveContextData(Session session) throws Exception {
    Context context = session.getContext(getContextId());
    context.setExcludeFromContextRegexs(regexesPanel.getRegexes());
}
Also used : Context(org.zaproxy.zap.model.Context)

Aggregations

Context (org.zaproxy.zap.model.Context)89 ApiException (org.zaproxy.zap.extension.api.ApiException)22 Test (org.junit.jupiter.api.Test)21 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)17 WithConfigsTest (org.zaproxy.zap.WithConfigsTest)16 User (org.zaproxy.zap.users.User)15 JSONObject (net.sf.json.JSONObject)14 Configuration (org.apache.commons.configuration.Configuration)14 Session (org.parosproxy.paros.model.Session)14 ApiDynamicActionImplementor (org.zaproxy.zap.extension.api.ApiDynamicActionImplementor)13 RecordContext (org.parosproxy.paros.db.RecordContext)12 DatabaseException (org.parosproxy.paros.db.DatabaseException)10 ConfigurationException (org.apache.commons.configuration.ConfigurationException)9 HttpMessage (org.parosproxy.paros.network.HttpMessage)9 ExtensionUserManagement (org.zaproxy.zap.extension.users.ExtensionUserManagement)9 ArrayList (java.util.ArrayList)8 JMenuItem (javax.swing.JMenuItem)7 ExtensionPopupMenuItem (org.parosproxy.paros.extension.ExtensionPopupMenuItem)7 SiteNode (org.parosproxy.paros.model.SiteNode)7 IOException (java.io.IOException)6