idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
20,400 | private void saveClientCertSettings ( ) { if ( getBoolean ( PERSIST_CLIENT_CERT , false ) ) { logger . warn ( "Saving Client Certificate settings: password will be found in config" ) ; setUseClientCert ( getBoolean ( USE_CLIENT_CERT , false ) ) ; setClientCertLocation ( getString ( CLIENT_CERT_LOCATION , "" ) ) ; setClientCertPassword ( getString ( CLIENT_CERT_PASSWORD , "" ) ) ; setClientCertIndex ( getInt ( CLIENT_CERT_INDEX , 0 ) ) ; } else { setUseClientCert ( false ) ; setClientCertLocation ( "" ) ; setClientCertPassword ( "" ) ; setClientCertIndex ( 0 ) ; } } | Saves the client cert settings if the flag is set explicitly . Only works for the CLI currently . |
20,401 | private void clientCertCheck ( ) { boolean enableClientCert = getBoolean ( USE_CLIENT_CERT , false ) ; String certPath = getString ( CLIENT_CERT_LOCATION , "" ) ; String certPass = getString ( CLIENT_CERT_PASSWORD , "" ) ; int certIndex = getInt ( CLIENT_CERT_INDEX , 0 ) ; if ( enableClientCert && ! certPath . isEmpty ( ) && ! certPass . isEmpty ( ) ) { try { SSLContextManager contextManager = getSSLContextManager ( ) ; int ksIndex = contextManager . loadPKCS12Certificate ( certPath , certPass ) ; contextManager . unlockKey ( ksIndex , certIndex , certPass ) ; contextManager . setDefaultKey ( ksIndex , certIndex ) ; setActiveCertificate ( ) ; setEnableCertificate ( true ) ; logger . info ( "Client Certificate enabled from CLI" ) ; logger . info ( "Use -config certificate.persist=true to save settings" ) ; } catch ( IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException ex ) { logger . error ( "The certificate could not be enabled due to an error" , ex ) ; } } } | Enables ClientCertificate from - config CLI parameters Requires location password and a flag to use client certificate . |
20,402 | public List < BreakpointMessageInterface > getBreakpointsEnabledList ( ) { if ( mode . equals ( Mode . safe ) ) { return new ArrayList < > ( ) ; } return getBreakpointsModel ( ) . getBreakpointsEnabledList ( ) ; } | Exposes list of enabled breakpoints . |
20,403 | public int findInContent ( String content ) { int n = content . length ( ) ; int m = pattern . length ( ) ; int skip ; char val ; for ( int i = 0 ; i <= n - m ; i = i + skip ) { skip = 0 ; for ( int j = m - 1 ; j >= 0 ; j -- ) { if ( pattern . charAt ( j ) != content . charAt ( i + j ) ) { val = content . charAt ( i + j ) ; skip = ( occurrence . get ( val ) != null ) ? Math . max ( 1 , j - occurrence . get ( val ) ) : j + 1 ; break ; } } if ( skip == 0 ) { return i ; } } return - 1 ; } | Returns the index within this string of the first occurrence of the specified substring . If it is not a substring return - 1 . |
20,404 | private ExtensionSpider getExtensionSpider ( ) { if ( extension == null ) { extension = Control . getSingleton ( ) . getExtensionLoader ( ) . getExtension ( ExtensionSpider . class ) ; } return extension ; } | Gets the extension spider . |
20,405 | public Component getTableCellEditorComponent ( JTable table , Object value , boolean isSelected , int rowIndex , int vColIndex ) { if ( isSelected ) { } button . setText ( ( String ) value ) ; row = rowIndex ; return button ; } | This method is called when a cell value is edited by the user . |
20,406 | public void setScanHeadersAllRequests ( boolean scanAllRequests ) { if ( scanAllRequests == scanHeadersAllRequests ) { return ; } this . scanHeadersAllRequests = scanAllRequests ; getConfig ( ) . setProperty ( SCAN_HEADERS_ALL_REQUESTS , this . scanHeadersAllRequests ) ; } | Sets whether or not the HTTP Headers of all requests should be scanned not just requests that send parameters through the query or request body . |
20,407 | public static void removeAllSeparators ( JPopupMenu popupMenu ) { for ( int i = 0 ; i < popupMenu . getComponentCount ( ) ; i ++ ) { if ( isPopupMenuSeparator ( popupMenu . getComponent ( i ) ) ) { popupMenu . remove ( i ) ; i -- ; } } } | Removes all separators from the given pop up menu . |
20,408 | public static boolean addSeparatorIfNeeded ( JPopupMenu popupMenu ) { final int menuComponentCount = popupMenu . getComponentCount ( ) ; if ( menuComponentCount == 0 ) { return false ; } final Component lastMenuComponent = popupMenu . getComponent ( menuComponentCount - 1 ) ; if ( isPopupMenuSeparator ( lastMenuComponent ) ) { return false ; } popupMenu . addSeparator ( ) ; return true ; } | Appends a separator to the end of the menu if it exists at least one non separator menu component immediately before and if there isn t already a separator at the end of the menu . |
20,409 | public List < Integer > getHistoryIdsOfHistType ( long sessionId , int ... histTypes ) throws DatabaseException { return getHistoryIdsByParams ( sessionId , 0 , true , histTypes ) ; } | Gets all the history record IDs of the given session and with the given history types . |
20,410 | public Context getContext ( ) { if ( context == null ) { context = Model . getSingleton ( ) . getSession ( ) . getContext ( this . contextId ) ; } return context ; } | Lazy loader for getting the context to which this user corresponds . |
20,411 | public void authenticate ( ) { log . info ( "Authenticating user: " + this . name ) ; WebSession result = null ; try { result = getContext ( ) . getAuthenticationMethod ( ) . authenticate ( getContext ( ) . getSessionManagementMethod ( ) , this . authenticationCredentials , this ) ; } catch ( UnsupportedAuthenticationCredentialsException e ) { log . error ( "User does not have the expected type of credentials:" , e ) ; } synchronized ( this ) { this . lastSuccessfulAuthTime = System . currentTimeMillis ( ) ; this . authenticatedSession = result ; } } | Authenticates the user using its authentication credentials and the authentication method corresponding to its Context . |
20,412 | private static ExtensionAuthentication getAuthenticationExtension ( ) { if ( extensionAuth == null ) { extensionAuth = Control . getSingleton ( ) . getExtensionLoader ( ) . getExtension ( ExtensionAuthentication . class ) ; } return extensionAuth ; } | Gets a reference to the authentication extension . |
20,413 | public static String encode ( User user ) { StringBuilder out = new StringBuilder ( ) ; out . append ( user . id ) . append ( FIELD_SEPARATOR ) ; out . append ( user . isEnabled ( ) ) . append ( FIELD_SEPARATOR ) ; out . append ( Base64 . encodeBase64String ( user . name . getBytes ( ) ) ) . append ( FIELD_SEPARATOR ) ; out . append ( user . getContext ( ) . getAuthenticationMethod ( ) . getType ( ) . getUniqueIdentifier ( ) ) . append ( FIELD_SEPARATOR ) ; out . append ( user . authenticationCredentials . encode ( FIELD_SEPARATOR ) ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "Encoded user: " + out . toString ( ) ) ; return out . toString ( ) ; } | Encodes the User in a String . Fields that contain strings are Base64 encoded . |
20,414 | private void initContextPanel ( AbstractContextPropertiesPanel contextPanel ) { Context ctx = uiContexts . get ( contextPanel . getContextIndex ( ) ) ; if ( ctx != null ) { contextPanel . initContextData ( session , ctx ) ; } } | Initialises the given panel with the current session and the corresponding UI shared context . |
20,415 | public void recreateUISharedContexts ( Session session ) { uiContexts . clear ( ) ; for ( Context context : session . getContexts ( ) ) { Context uiContext = context . duplicate ( ) ; uiContexts . put ( context . getIndex ( ) , uiContext ) ; } } | Reset the UI shared Context copies . The effect is that previous copies are discarded and new copies are created . |
20,416 | private static boolean hasSameDefaultAccelerator ( KeyboardMapping km , KeyStroke ks ) { KeyStroke kmKs = km . getDefaultKeyStroke ( ) ; if ( kmKs == null ) { return false ; } return kmKs . getKeyCode ( ) == ks . getKeyCode ( ) && kmKs . getModifiers ( ) == ks . getModifiers ( ) ; } | Tells whether or not the given keyboard mapping has the given default accelerator . |
20,417 | private KeyStroke getDefaultAccelerator ( ZapMenuItem menuItem ) { if ( isIdentifierWithDuplicatedAccelerator ( menuItem . getIdentifier ( ) ) ) { return null ; } return menuItem . getDefaultAccelerator ( ) ; } | Gets the default accelerator of the given menu taken into account duplicated default accelerators . |
20,418 | public void setTokenValue ( String tokenName , Cookie value ) { if ( value == null ) { tokenValues . remove ( tokenName ) ; } else { tokenValues . put ( tokenName , value ) ; } } | Sets a particular value for a session token . If the value is null that token is deleted from the session . |
20,419 | public String getTokenValue ( String tokenName ) { Cookie ck = tokenValues . get ( tokenName ) ; if ( ck != null ) { return ck . getValue ( ) ; } return null ; } | Gets the token value . |
20,420 | public String getTokenValuesString ( ) { if ( tokenValues . isEmpty ( ) ) { return "" ; } StringBuilder buf = new StringBuilder ( ) ; for ( Map . Entry < String , Cookie > entry : tokenValues . entrySet ( ) ) { buf . append ( entry . getKey ( ) ) . append ( '=' ) . append ( entry . getValue ( ) . getValue ( ) ) . append ( ';' ) ; } buf . deleteCharAt ( buf . length ( ) - 1 ) ; return buf . toString ( ) ; } | Gets the token values string representation . |
20,421 | public final void setBackgroundImage ( URL imageUrl ) { if ( imageUrl != null ) { try { img = ImageIO . read ( imageUrl ) ; } catch ( IOException ioe ) { } } } | set the current Background image |
20,422 | protected void paintComponent ( Graphics g ) { if ( img != null ) { setOpaque ( false ) ; Map < RenderingHints . Key , Object > hints = new HashMap < RenderingHints . Key , Object > ( ) ; hints . put ( RenderingHints . KEY_INTERPOLATION , RenderingHints . VALUE_INTERPOLATION_BICUBIC ) ; hints . put ( RenderingHints . KEY_RENDERING , RenderingHints . VALUE_RENDER_QUALITY ) ; hints . put ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; ( ( Graphics2D ) g ) . addRenderingHints ( hints ) ; g . drawImage ( img , 0 , 0 , ( int ) ( DisplayUtils . getScaledSize ( img . getWidth ( ) ) * scale ) , ( int ) ( DisplayUtils . getScaledSize ( img . getHeight ( ) ) * scale ) , null ) ; } super . paintComponent ( g ) ; } | Overridden method to paint a background before the rest |
20,423 | protected boolean handleCmdLineSessionArgsSynchronously ( Control control ) { if ( getArgs ( ) . isEnabled ( CommandLine . SESSION ) && getArgs ( ) . isEnabled ( CommandLine . NEW_SESSION ) ) { System . err . println ( "Error: Invalid command line options: option '" + CommandLine . SESSION + "' not allowed with option '" + CommandLine . NEW_SESSION + "'" ) ; return false ; } if ( getArgs ( ) . isEnabled ( CommandLine . SESSION ) ) { Path sessionPath = SessionUtils . getSessionPath ( getArgs ( ) . getArgument ( CommandLine . SESSION ) ) ; String absolutePath = sessionPath . toAbsolutePath ( ) . toString ( ) ; try { control . runCommandLineOpenSession ( absolutePath ) ; } catch ( Exception e ) { getLogger ( ) . error ( e . getMessage ( ) , e ) ; System . err . println ( "Failed to open session: " + absolutePath ) ; e . printStackTrace ( System . err ) ; return false ; } } else if ( getArgs ( ) . isEnabled ( CommandLine . NEW_SESSION ) ) { Path sessionPath = SessionUtils . getSessionPath ( getArgs ( ) . getArgument ( CommandLine . NEW_SESSION ) ) ; String absolutePath = sessionPath . toAbsolutePath ( ) . toString ( ) ; if ( Files . exists ( sessionPath ) ) { System . err . println ( "Failed to create a new session, file already exists: " + absolutePath ) ; return false ; } try { control . runCommandLineNewSession ( absolutePath ) ; } catch ( Exception e ) { getLogger ( ) . error ( e . getMessage ( ) , e ) ; System . err . println ( "Failed to create a new session: " + absolutePath ) ; e . printStackTrace ( System . err ) ; return false ; } } return true ; } | Handles command line session related arguments synchronously . |
20,424 | protected void warnAddOnsAndExtensionsNoLongerRunnable ( ) { final AddOnLoader addOnLoader = ExtensionFactory . getAddOnLoader ( ) ; List < String > idsAddOnsNoLongerRunning = addOnLoader . getIdsAddOnsWithRunningIssuesSinceLastRun ( ) ; if ( idsAddOnsNoLongerRunning . isEmpty ( ) ) { return ; } List < AddOn > addOnsNoLongerRunning = new ArrayList < > ( idsAddOnsNoLongerRunning . size ( ) ) ; for ( String id : idsAddOnsNoLongerRunning ) { addOnsNoLongerRunning . add ( addOnLoader . getAddOnCollection ( ) . getAddOn ( id ) ) ; } for ( AddOn addOn : addOnsNoLongerRunning ) { AddOn . AddOnRunRequirements requirements = addOn . calculateRunRequirements ( addOnLoader . getAddOnCollection ( ) . getAddOns ( ) ) ; List < String > issues = AddOnRunIssuesUtils . getRunningIssues ( requirements ) ; if ( issues . isEmpty ( ) ) { issues = AddOnRunIssuesUtils . getExtensionsRunningIssues ( requirements ) ; } getLogger ( ) . warn ( "Add-on \"" + addOn . getId ( ) + "\" or its extensions will no longer be run until its requirements are restored: " + issues ) ; } } | Warns through logging about add - ons and extensions that are no longer runnable because of changes in its dependencies . |
20,425 | private boolean isCertExpired ( X509Certificate cert ) { if ( cert != null && cert . getNotAfter ( ) . before ( new Date ( ) ) ) { return true ; } return false ; } | Returns true if the certificate expired before the current date otherwise false . |
20,426 | private void warnRooCaCertExpired ( ) { X509Certificate cert = getRootCaCertificate ( ) ; if ( cert == null ) { return ; } String warnMsg = Constant . messages . getString ( "dynssl.warn.cert.expired" , cert . getNotAfter ( ) . toString ( ) , new Date ( ) . toString ( ) ) ; if ( View . isInitialised ( ) ) { getView ( ) . showWarningDialog ( warnMsg ) ; } logger . warn ( warnMsg ) ; } | Displays a warning dialog and logs a warning message if ZAPs Root CA certificate has expired . |
20,427 | protected JComboBox < AuthenticationMethodType > getAuthenticationMethodsComboBox ( ) { if ( authenticationMethodsComboBox == null ) { Vector < AuthenticationMethodType > methods = new Vector < > ( extension . getAuthenticationMethodTypes ( ) ) ; authenticationMethodsComboBox = new JComboBox < > ( methods ) ; authenticationMethodsComboBox . setSelectedItem ( null ) ; authenticationMethodsComboBox . addItemListener ( new ItemListener ( ) { public void itemStateChanged ( ItemEvent e ) { if ( e . getStateChange ( ) == ItemEvent . SELECTED && ! e . getItem ( ) . equals ( shownMethodType ) ) { log . debug ( "Selected new Authentication type: " + e . getItem ( ) ) ; AuthenticationMethodType type = ( ( AuthenticationMethodType ) e . getItem ( ) ) ; if ( shownMethodType == null || type . getAuthenticationCredentialsType ( ) != shownMethodType . getAuthenticationCredentialsType ( ) ) { if ( needsConfirm && ! confirmAndResetUsersCredentials ( type ) ) { log . debug ( "Cancelled change of authentication type." ) ; authenticationMethodsComboBox . setSelectedItem ( shownMethodType ) ; return ; } } resetLoggedInOutIndicators ( ) ; if ( selectedAuthenticationMethod == null || ! type . isTypeForMethod ( selectedAuthenticationMethod ) ) { selectedAuthenticationMethod = type . createAuthenticationMethod ( getContextIndex ( ) ) ; } changeMethodConfigPanel ( type ) ; if ( type . hasOptionsPanel ( ) ) { shownConfigPanel . bindMethod ( selectedAuthenticationMethod , getAuthenticationIndicatorsPanel ( ) ) ; } } } } ) ; } return authenticationMethodsComboBox ; } | Gets the authentication method types combo box . |
20,428 | private boolean confirmAndResetUsersCredentials ( AuthenticationMethodType type ) { ExtensionUserManagement usersExtension = Control . getSingleton ( ) . getExtensionLoader ( ) . getExtension ( ExtensionUserManagement . class ) ; if ( usersExtension == null ) { return true ; } List < User > users = usersExtension . getSharedContextUsers ( getUISharedContext ( ) ) ; if ( users . isEmpty ( ) ) { return true ; } if ( users . stream ( ) . anyMatch ( user -> user . getAuthenticationCredentials ( ) . isConfigured ( ) ) ) { authenticationMethodsComboBox . transferFocus ( ) ; int choice = JOptionPane . showConfirmDialog ( this , Constant . messages . getString ( "authentication.dialog.confirmChange.label" ) , Constant . messages . getString ( "authentication.dialog.confirmChange.title" ) , JOptionPane . OK_CANCEL_OPTION ) ; if ( choice == JOptionPane . CANCEL_OPTION ) { return false ; } } users . replaceAll ( user -> { User modifiedUser = new User ( user . getContextId ( ) , user . getName ( ) , user . getId ( ) ) ; modifiedUser . setEnabled ( false ) ; modifiedUser . setAuthenticationCredentials ( type . createAuthenticationCredentials ( ) ) ; return modifiedUser ; } ) ; return true ; } | Make sure the user acknowledges the Users corresponding to this context will have the credentials changed with the new type of authentication method . |
20,429 | public String getString ( String key ) { Object obj = get ( key ) ; if ( obj != null && obj instanceof String ) { return ( String ) obj ; } return null ; } | Get the first item in KB matching the key as a String . |
20,430 | public synchronized boolean stopServer ( ) { if ( ! isProxyRunning ) { return false ; } isProxyRunning = false ; HttpUtil . closeServerSocket ( proxySocket ) ; try { thread . join ( ) ; } catch ( Exception e ) { } proxySocket = null ; return true ; } | Stops the proxy server . |
20,431 | private ZapMenuItem getMenuItemPolicy ( ) { if ( menuItemPolicy == null ) { menuItemPolicy = new ZapMenuItem ( "menu.analyse.scanPolicy" , getView ( ) . getMenuShortcutKeyStroke ( KeyEvent . VK_P , 0 , false ) ) ; menuItemPolicy . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { showPolicyManagerDialog ( ) ; } } ) ; } return menuItemPolicy ; } | This method initializes menuItemPolicy |
20,432 | public void showCustomScanDialog ( Target target ) { if ( customScanDialog == null ) { String [ ] tabs = CustomScanDialog . STD_TAB_LABELS ; if ( this . customScanPanels . size ( ) > 0 ) { List < String > tabList = new ArrayList < String > ( ) ; for ( String str : CustomScanDialog . STD_TAB_LABELS ) { tabList . add ( str ) ; } for ( CustomScanPanel csp : customScanPanels ) { tabList . add ( csp . getLabel ( ) ) ; } tabs = tabList . toArray ( new String [ tabList . size ( ) ] ) ; } customScanDialog = new CustomScanDialog ( this , tabs , this . customScanPanels , View . getSingleton ( ) . getMainFrame ( ) , new Dimension ( 700 , 500 ) ) ; } if ( customScanDialog . isVisible ( ) ) { customScanDialog . requestFocus ( ) ; customScanDialog . toFront ( ) ; return ; } if ( target != null ) { customScanDialog . init ( target ) ; } else { customScanDialog . init ( null ) ; } customScanDialog . setVisible ( true ) ; } | Shows the active scan dialogue with the given target if not already visible . |
20,433 | protected void readResponseBody ( HttpState state , HttpConnection conn ) throws HttpException , IOException { LOG . trace ( "enter HeadMethod.readResponseBody(HttpState, HttpConnection)" ) ; int bodyCheckTimeout = getParams ( ) . getIntParameter ( HttpMethodParams . HEAD_BODY_CHECK_TIMEOUT , - 1 ) ; if ( bodyCheckTimeout < 0 ) { responseBodyConsumed ( ) ; } else { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Check for non-compliant response body. Timeout in " + bodyCheckTimeout + " ms" ) ; } boolean responseAvailable = false ; try { responseAvailable = conn . isResponseAvailable ( bodyCheckTimeout ) ; } catch ( IOException e ) { LOG . debug ( "An IOException occurred while testing if a response was available," + " we will assume one is not." , e ) ; responseAvailable = false ; } if ( responseAvailable ) { if ( getParams ( ) . isParameterTrue ( HttpMethodParams . REJECT_HEAD_BODY ) ) { throw new ProtocolException ( "Body content may not be sent in response to HTTP HEAD request" ) ; } else { LOG . warn ( "Body content returned in response to HTTP HEAD" ) ; } super . readResponseBody ( state , conn ) ; } } } | Implementation copied from HeadMethod . |
20,434 | public void clearFields ( ) { this . requiredFields = NO_FIELDS ; this . optionalFields = NO_FIELDS ; this . textFields = Collections . emptyMap ( ) ; removeAll ( ) ; validate ( ) ; } | Clears all the fields leaving an empty panel . |
20,435 | public Map < String , String > getFieldValues ( ) { Map < String , String > values = new HashMap < > ( requiredFields . length + optionalFields . length ) ; for ( Entry < String , ZapTextField > f : textFields . entrySet ( ) ) values . put ( f . getKey ( ) , f . getValue ( ) . getText ( ) ) ; return values ; } | Gets a mapping of the field names to the configured field values . |
20,436 | public void validateFields ( ) throws IllegalStateException { for ( String rf : requiredFields ) if ( textFields . get ( rf ) . getText ( ) . trim ( ) . isEmpty ( ) ) { textFields . get ( rf ) . requestFocusInWindow ( ) ; throw new IllegalStateException ( Constant . messages . getString ( "authentication.method.script.dialog.error.text.required" , rf ) ) ; } } | Validate the fields of the panel checking that all the required fields has been filled . If any of the fields are not in the proper state an IllegalStateException is thrown containing a message describing the problem . |
20,437 | private ZapTextArea getTxtOutput ( ) { if ( txtOutput == null ) { txtOutput = new ZapTextArea ( ) ; txtOutput . setEditable ( false ) ; txtOutput . setLineWrap ( true ) ; txtOutput . setName ( "" ) ; txtOutput . addMouseListener ( new java . awt . event . MouseAdapter ( ) { public void mousePressed ( java . awt . event . MouseEvent e ) { showPopupMenuIfTriggered ( e ) ; } public void mouseReleased ( java . awt . event . MouseEvent e ) { showPopupMenuIfTriggered ( e ) ; } private void showPopupMenuIfTriggered ( java . awt . event . MouseEvent e ) { if ( e . isPopupTrigger ( ) ) { View . getSingleton ( ) . getPopupMenu ( ) . show ( e . getComponent ( ) , e . getX ( ) , e . getY ( ) ) ; } } } ) ; } return txtOutput ; } | This method initializes txtOutput |
20,438 | private JPanel getJPanelBottom ( ) { if ( jPanelBottom == null ) { GridBagConstraints gridBagConstraints2 = new GridBagConstraints ( ) ; gridBagConstraints2 . insets = new java . awt . Insets ( 5 , 3 , 5 , 5 ) ; gridBagConstraints2 . gridy = 0 ; gridBagConstraints2 . anchor = java . awt . GridBagConstraints . EAST ; gridBagConstraints2 . gridx = 2 ; GridBagConstraints gridBagConstraints3 = new GridBagConstraints ( ) ; gridBagConstraints3 . insets = new java . awt . Insets ( 5 , 3 , 5 , 2 ) ; gridBagConstraints3 . gridy = 0 ; gridBagConstraints3 . anchor = java . awt . GridBagConstraints . WEST ; gridBagConstraints3 . gridx = 3 ; GridBagConstraints gridBagConstraints1 = new GridBagConstraints ( ) ; gridBagConstraints1 . insets = new java . awt . Insets ( 5 , 3 , 5 , 2 ) ; gridBagConstraints1 . gridy = 0 ; gridBagConstraints1 . anchor = java . awt . GridBagConstraints . WEST ; gridBagConstraints1 . gridx = 1 ; GridBagConstraints gridBagConstraints = new GridBagConstraints ( ) ; gridBagConstraints . insets = new java . awt . Insets ( 10 , 5 , 10 , 2 ) ; gridBagConstraints . gridy = 0 ; gridBagConstraints . fill = java . awt . GridBagConstraints . HORIZONTAL ; gridBagConstraints . anchor = java . awt . GridBagConstraints . WEST ; gridBagConstraints . weighty = 1.0D ; gridBagConstraints . weightx = 1.0D ; gridBagConstraints . gridx = 0 ; jLabel = new JLabel ( ) ; jLabel . setText ( " " ) ; jLabel . setComponentOrientation ( java . awt . ComponentOrientation . UNKNOWN ) ; jPanelBottom = new JPanel ( ) ; jPanelBottom . setLayout ( new GridBagLayout ( ) ) ; jPanelBottom . add ( jLabel , gridBagConstraints ) ; jPanelBottom . add ( getBtnCapture ( ) , gridBagConstraints1 ) ; jPanelBottom . add ( getBtnStop ( ) , gridBagConstraints2 ) ; jPanelBottom . add ( getBtnClose ( ) , gridBagConstraints3 ) ; } return jPanelBottom ; } | This method initializes jPanelBottom |
20,439 | private JButton getBtnClose ( ) { if ( btnClose == null ) { btnClose = new JButton ( ) ; btnClose . setText ( "Close" ) ; btnClose . setVisible ( false ) ; btnClose . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent arg0 ) { stop ( ) ; } } ) ; } return btnClose ; } | This method initializes jButton1 |
20,440 | private JTextPane getTxtLicense ( ) { if ( txtLicense == null ) { txtLicense = new JTextPane ( ) ; txtLicense . setName ( "txtLicense" ) ; txtLicense . setEditable ( false ) ; } return txtLicense ; } | This method initializes txtLicense |
20,441 | public boolean isToExclude ( HttpMessage msg , NameValuePair param ) { return ( ( paramType == NameValuePair . TYPE_UNDEFINED ) || ( param . getType ( ) == paramType ) ) && ( ( urlPattern == null ) || urlPattern . matcher ( msg . getRequestHeader ( ) . getURI ( ) . toString ( ) . toUpperCase ( Locale . ROOT ) ) . matches ( ) ) && ( paramNamePattern . matcher ( param . getName ( ) ) . matches ( ) ) ; } | Check if the parameter should be excluded by the scanner |
20,442 | public JTree getTreeSite ( ) { if ( treeSite == null ) { treeSite = new JTree ( new DefaultTreeModel ( new DefaultMutableTreeNode ( ) ) ) ; treeSite . setShowsRootHandles ( true ) ; treeSite . setName ( "treeSite" ) ; treeSite . setToggleClickCount ( 1 ) ; LookAndFeel laf = UIManager . getLookAndFeel ( ) ; if ( laf != null && Constant . isMacOsX ( ) && UIManager . getSystemLookAndFeelClassName ( ) . equals ( laf . getClass ( ) . getName ( ) ) ) { treeSite . setRowHeight ( 0 ) ; } treeSite . addTreeSelectionListener ( new javax . swing . event . TreeSelectionListener ( ) { public void valueChanged ( javax . swing . event . TreeSelectionEvent e ) { SiteNode node = ( SiteNode ) treeSite . getLastSelectedPathComponent ( ) ; if ( node == null ) { return ; } if ( ! node . isRoot ( ) ) { HttpMessage msg = null ; try { msg = node . getHistoryReference ( ) . getHttpMessage ( ) ; } catch ( Exception e1 ) { log . warn ( e1 . getMessage ( ) , e1 ) ; return ; } getView ( ) . displayMessage ( msg ) ; for ( SiteMapListener listener : listeners ) { listener . nodeSelected ( node ) ; } } else { getView ( ) . displayMessage ( null ) ; } } } ) ; treeSite . setComponentPopupMenu ( new SitesCustomPopupMenu ( ) ) ; DefaultTreeCellRenderer renderer = new SiteMapTreeCellRenderer ( listeners ) ; treeSite . setCellRenderer ( renderer ) ; String deleteSiteNode = "zap.delete.sitenode" ; treeSite . getInputMap ( ) . put ( getView ( ) . getDefaultDeleteKeyStroke ( ) , deleteSiteNode ) ; treeSite . getActionMap ( ) . put ( deleteSiteNode , new AbstractAction ( ) { private static final long serialVersionUID = 1L ; public void actionPerformed ( ActionEvent e ) { ExtensionHistory extHistory = Control . getSingleton ( ) . getExtensionLoader ( ) . getExtension ( ExtensionHistory . class ) ; if ( extHistory == null || treeSite . getSelectionCount ( ) == 0 ) { return ; } int result = View . getSingleton ( ) . showConfirmDialog ( Constant . messages . getString ( "sites.purge.warning" ) ) ; if ( result != JOptionPane . YES_OPTION ) { return ; } SiteMap siteMap = Model . getSingleton ( ) . getSession ( ) . getSiteTree ( ) ; for ( TreePath path : treeSite . getSelectionPaths ( ) ) { extHistory . purge ( siteMap , ( SiteNode ) path . getLastPathComponent ( ) ) ; } } } ) ; } return treeSite ; } | This method initializes treeSite |
20,443 | public int getProgressPercentage ( ) { if ( isRunning ( ) ) { int progress = ( hProcess . getTestCurrentCount ( plugin ) * 100 ) / hProcess . getTestTotalCount ( ) ; return progress >= 100 ? 99 : progress ; } else if ( isCompleted ( ) || isSkipped ( ) ) { return 100 ; } else { return 0 ; } } | Get back the percentage of completion . |
20,444 | void refresh ( ) { if ( isCompleted ( ) ) { return ; } if ( hProcess . getCompleted ( ) . contains ( plugin ) ) { status = STATUS_COMPLETED ; } else if ( hProcess . getRunning ( ) . contains ( plugin ) ) { status = STATUS_RUNNING ; } } | Refresh the state of this scan progress item . |
20,445 | protected void parse ( ) { maximumInstances = getInt ( PARAM_MAXIMUM_INSTANCES , DEFAULT_MAXIMUM_INSTANCES ) ; mergeRelatedIssues = getBoolean ( PARAM_MERGE_RELATED_ISSUES , true ) ; overridesFilename = getString ( PARAM_OVERRIDES_FILENAME , "" ) ; } | Parses the alert options . |
20,446 | public void setMaximumInstances ( int maximumInstances ) { int newValue = maximumInstances < 0 ? 0 : maximumInstances ; if ( this . maximumInstances != newValue ) { this . maximumInstances = newValue ; getConfig ( ) . setProperty ( PARAM_MAXIMUM_INSTANCES , this . maximumInstances ) ; } } | Sets the maximum instances of an alert to include in a report . |
20,447 | AlertPanel getAlertPanel ( ) { if ( alertPanel == null ) { alertPanel = new AlertPanel ( this ) ; alertPanel . setSize ( 345 , 122 ) ; setMainTreeModel ( ) ; } return alertPanel ; } | This method initializes alertPanel |
20,448 | public void showAlertEditDialog ( Alert alert ) { if ( dialogAlertAdd == null || ! dialogAlertAdd . isVisible ( ) ) { dialogAlertAdd = new AlertAddDialog ( getView ( ) . getMainFrame ( ) , false ) ; dialogAlertAdd . setVisible ( true ) ; dialogAlertAdd . setAlert ( alert ) ; } } | Shows the Edit Alert dialogue with the given alert . |
20,449 | public static String toHexString ( byte [ ] b ) { if ( null == b ) return null ; int len = b . length ; byte [ ] hex = new byte [ len << 1 ] ; for ( int i = 0 , j = 0 ; i < len ; i ++ , j += 2 ) { hex [ j ] = ( byte ) ( ( b [ i ] & 0xF0 ) >> 4 ) ; hex [ j ] += 10 > hex [ j ] ? 48 : 87 ; hex [ j + 1 ] = ( byte ) ( b [ i ] & 0x0F ) ; hex [ j + 1 ] += 10 > hex [ j + 1 ] ? 48 : 87 ; } return new String ( hex ) ; } | Converts a byte array into a hexadecimal String . |
20,450 | public static String hashSHA ( String str ) { byte [ ] b = str . getBytes ( ) ; MessageDigest md = null ; try { md = MessageDigest . getInstance ( "SHA1" ) ; md . update ( b ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } return toHexString ( md . digest ( ) ) ; } | Returns the SHA hash of a String . |
20,451 | public static synchronized String rot13 ( String input ) { StringBuffer output = new StringBuffer ( ) ; if ( input != null ) { for ( int i = 0 ; i < input . length ( ) ; i ++ ) { char inChar = input . charAt ( i ) ; if ( ( inChar >= 'A' ) & ( inChar <= 'Z' ) ) { inChar += 13 ; if ( inChar > 'Z' ) { inChar -= 26 ; } } if ( ( inChar >= 'a' ) & ( inChar <= 'z' ) ) { inChar += 13 ; if ( inChar > 'z' ) { inChar -= 26 ; } } output . append ( inChar ) ; } } return output . toString ( ) ; } | Description of the Method |
20,452 | public void load ( FileConfiguration config ) { this . config = config ; try { parse ( ) ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; } } | Loads the configurations from the given configuration file . |
20,453 | public void load ( String filePath , ControlOverrides overrides ) { try { config = new ZapXmlConfiguration ( filePath ) ; if ( overrides != null ) { for ( Entry < String , String > entry : overrides . getOrderedConfigs ( ) . entrySet ( ) ) { logger . info ( "Setting config " + entry . getKey ( ) + " = " + entry . getValue ( ) + " was " + config . getString ( entry . getKey ( ) ) ) ; config . setProperty ( entry . getKey ( ) , entry . getValue ( ) ) ; } } parse ( ) ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; } } | Loads the configurations from the file located at the given path and using the given overrides |
20,454 | protected Element [ ] getElements ( Element base , String childTag ) { NodeList nodeList = base . getElementsByTagName ( childTag ) ; if ( nodeList . getLength ( ) == 0 ) { return null ; } Element [ ] elements = new Element [ nodeList . getLength ( ) ] ; for ( int i = 0 ; i < nodeList . getLength ( ) ; i ++ ) { elements [ i ] = ( Element ) nodeList . item ( i ) ; } return elements ; } | Get all elements under a base element matching a tag name |
20,455 | private String getText ( Element element ) { try { for ( int i = 0 ; i < element . getChildNodes ( ) . getLength ( ) ; i ++ ) { Node node = element . getChildNodes ( ) . item ( i ) ; if ( node . getNodeType ( ) == Node . TEXT_NODE ) { return node . getNodeValue ( ) ; } } } catch ( Exception e ) { } return "" ; } | Get the text in text node from the element . |
20,456 | protected String getValue ( Element base , String tag ) { Element element = null ; String result = "" ; try { element = getElement ( base , tag ) ; result = getText ( element ) ; } catch ( Exception e ) { } return result ; } | Get the value of the tag under a base element |
20,457 | private ExtensionAuthentication getExtensionAuthentication ( ) { if ( extensionAuth == null ) { extensionAuth = Control . getSingleton ( ) . getExtensionLoader ( ) . getExtension ( ExtensionAuthentication . class ) ; } return extensionAuth ; } | Gets the authentication extension |
20,458 | private ExtensionUserManagement getExtensionUserManagement ( ) { if ( extensionUsers == null ) { extensionUsers = Control . getSingleton ( ) . getExtensionLoader ( ) . getExtension ( ExtensionUserManagement . class ) ; } return extensionUsers ; } | Gets the Users extension |
20,459 | private boolean parseSource ( HttpMessage message , Source source , int depth , String baseURL ) { log . debug ( "Parsing an HTML message..." ) ; boolean resourcesfound = false ; List < Element > elements = source . getAllElements ( HTMLElementName . A ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "href" ) ; } elements = source . getAllElements ( HTMLElementName . AREA ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "href" ) ; } elements = source . getAllElements ( HTMLElementName . FRAME ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "src" ) ; } elements = source . getAllElements ( HTMLElementName . IFRAME ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "src" ) ; } elements = source . getAllElements ( HTMLElementName . LINK ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "href" ) ; } elements = source . getAllElements ( HTMLElementName . SCRIPT ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "src" ) ; } elements = source . getAllElements ( HTMLElementName . IMG ) ; for ( Element el : elements ) { resourcesfound |= processAttributeElement ( message , depth , baseURL , el , "src" ) ; } elements = source . getAllElements ( HTMLElementName . META ) ; for ( Element el : elements ) { String equiv = el . getAttributeValue ( "http-equiv" ) ; String content = el . getAttributeValue ( "content" ) ; if ( equiv != null && content != null ) { if ( equiv . equalsIgnoreCase ( "refresh" ) || equiv . equalsIgnoreCase ( "location" ) ) { Matcher matcher = urlPattern . matcher ( content ) ; if ( matcher . find ( ) ) { String url = matcher . group ( 1 ) ; processURL ( message , depth , url , baseURL ) ; resourcesfound = true ; } } } } return resourcesfound ; } | Parses the HTML Jericho source for the elements that contain references to other resources . |
20,460 | private boolean processAttributeElement ( HttpMessage message , int depth , String baseURL , Element element , String attributeName ) { String localURL = element . getAttributeValue ( attributeName ) ; if ( localURL == null ) { return false ; } processURL ( message , depth , localURL , baseURL ) ; return true ; } | Processes the attribute with the given name of a Jericho element for an URL . If an URL is found notifies the listeners . |
20,461 | public void appendMsg ( final String msg ) { if ( ! EventQueue . isDispatchThread ( ) ) { try { EventQueue . invokeAndWait ( new Runnable ( ) { public void run ( ) { appendMsg ( msg ) ; } } ) ; } catch ( InvocationTargetException e ) { LOGGER . error ( "Failed to append message: " , e ) ; } catch ( InterruptedException ignore ) { } return ; } displayRandomTip ( ) ; getLogPanel ( ) . append ( msg ) ; JScrollBar vertical = getLogJScrollPane ( ) . getVerticalScrollBar ( ) ; vertical . setValue ( vertical . getMaximum ( ) ) ; } | Append a message to the output window of this splash screen |
20,462 | private void validateTabbed ( int tabIndex ) { if ( ! isTabbed ( ) ) { throw new IllegalArgumentException ( "Not initialised as a tabbed dialog - must use method without tab parameters" ) ; } if ( tabIndex < 0 || tabIndex >= this . tabPanels . size ( ) ) { throw new IllegalArgumentException ( "Invalid tab index: " + tabIndex ) ; } } | Validates that the dialogue is tabbed and the given tab index is valid . |
20,463 | public void addTableField ( String fieldLabel , JTable field , List < JButton > buttons ) { validateNotTabbed ( ) ; JScrollPane scrollPane = new JScrollPane ( ) ; scrollPane . setVerticalScrollBarPolicy ( JScrollPane . VERTICAL_SCROLLBAR_AS_NEEDED ) ; scrollPane . setViewportView ( field ) ; field . setFillsViewportHeight ( true ) ; if ( this . fieldList . contains ( field ) ) { throw new IllegalArgumentException ( "Field already added: " + field ) ; } if ( buttons == null || buttons . size ( ) == 0 ) { if ( fieldLabel == null ) { this . getMainPanel ( ) . add ( scrollPane , LayoutHelper . getGBC ( 1 , this . fieldList . size ( ) , 1 , fieldWeight , 1.0D , GridBagConstraints . BOTH , new Insets ( 4 , 4 , 4 , 4 ) ) ) ; } else { this . addField ( fieldLabel , field , scrollPane , 1.0D ) ; } } else { JPanel tablePanel = new JPanel ( ) ; tablePanel . setLayout ( new GridBagLayout ( ) ) ; tablePanel . add ( scrollPane , LayoutHelper . getGBC ( 0 , 0 , 1 , 1.0D , 1.0D , GridBagConstraints . BOTH , new Insets ( 4 , 4 , 4 , 4 ) ) ) ; JPanel buttonPanel = new JPanel ( ) ; buttonPanel . setLayout ( new GridBagLayout ( ) ) ; int buttonId = 0 ; for ( JButton button : buttons ) { buttonPanel . add ( button , LayoutHelper . getGBC ( 0 , buttonId ++ , 1 , 0D , 0D , GridBagConstraints . BOTH , new Insets ( 2 , 2 , 2 , 2 ) ) ) ; } buttonPanel . add ( new JLabel ( ) , LayoutHelper . getGBC ( 0 , buttonId ++ , 1 , 0D , 1.0D , GridBagConstraints . BOTH , new Insets ( 2 , 2 , 2 , 2 ) ) ) ; tablePanel . add ( buttonPanel , LayoutHelper . getGBC ( 1 , 0 , 1 , 0D , 0D , GridBagConstraints . BOTH , new Insets ( 2 , 2 , 2 , 2 ) ) ) ; if ( fieldLabel == null ) { this . getMainPanel ( ) . add ( tablePanel , LayoutHelper . getGBC ( 1 , this . fieldList . size ( ) , 1 , fieldWeight , 1.0D , GridBagConstraints . BOTH , new Insets ( 4 , 4 , 4 , 4 ) ) ) ; } else { this . addField ( fieldLabel , field , tablePanel , 1.0D ) ; } } this . fieldList . add ( field ) ; } | Add a table field . |
20,464 | public void setTabsVisible ( String [ ] tabLabels , boolean visible ) { if ( visible ) { for ( String label : tabLabels ) { String name = Constant . messages . getString ( label ) ; JPanel tabPanel = this . tabNameMap . get ( label ) ; tabbedPane . addTab ( name , getTabComponent ( tabPanel ) ) ; } } else { for ( String label : tabLabels ) { JPanel tabPanel = this . tabNameMap . get ( label ) ; this . tabbedPane . remove ( getTabComponent ( tabPanel ) ) ; } } } | Set the visibility of the specified tabs . The labels must have been used to create the tabs in the constructor |
20,465 | public static ValidationResult isValidAddOn ( Path file ) { if ( file == null || file . getNameCount ( ) == 0 ) { return new ValidationResult ( ValidationResult . Validity . INVALID_PATH ) ; } if ( ! isAddOnFileName ( file . getFileName ( ) . toString ( ) ) ) { return new ValidationResult ( ValidationResult . Validity . INVALID_FILE_NAME ) ; } if ( ! Files . isRegularFile ( file ) || ! Files . isReadable ( file ) ) { return new ValidationResult ( ValidationResult . Validity . FILE_NOT_READABLE ) ; } try ( ZipFile zip = new ZipFile ( file . toFile ( ) ) ) { ZipEntry manifest = zip . getEntry ( MANIFEST_FILE_NAME ) ; if ( manifest == null ) { return new ValidationResult ( ValidationResult . Validity . MISSING_MANIFEST ) ; } try ( InputStream zis = zip . getInputStream ( manifest ) ) { try { return new ValidationResult ( new ZapAddOnXmlFile ( zis ) ) ; } catch ( Exception e ) { return new ValidationResult ( ValidationResult . Validity . INVALID_MANIFEST , e ) ; } } } catch ( ZipException e ) { return new ValidationResult ( ValidationResult . Validity . UNREADABLE_ZIP_FILE , e ) ; } catch ( Exception e ) { return new ValidationResult ( ValidationResult . Validity . IO_ERROR_FILE , e ) ; } } | Tells whether or not the given file is a ZAP add - on . |
20,466 | public List < Extension > getLoadedExtensionsWithDeps ( ) { List < String > classnames = getExtensionsWithDeps ( ) ; ArrayList < Extension > loadedExtensions = new ArrayList < > ( extensionsWithDeps . size ( ) ) ; for ( Extension extension : getLoadedExtensions ( ) ) { if ( classnames . contains ( extension . getClass ( ) . getCanonicalName ( ) ) ) { loadedExtensions . add ( extension ) ; } } loadedExtensions . trimToSize ( ) ; return loadedExtensions ; } | Gets the extensions of this add - on that have dependencies and were loaded . |
20,467 | public List < Extension > getLoadedExtensions ( ) { if ( loadedExtensions == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( loadedExtensions ) ; } | Gets the extensions of this add - on that were loaded . |
20,468 | public List < String > getIdsAddOnDependencies ( ) { if ( dependencies == null ) { return Collections . emptyList ( ) ; } List < String > ids = new ArrayList < > ( dependencies . getAddOns ( ) . size ( ) ) ; for ( AddOnDep dep : dependencies . getAddOns ( ) ) { ids . add ( dep . getId ( ) ) ; } return ids ; } | Returns the IDs of the add - ons dependencies an empty collection if none . |
20,469 | public void generateAPIFiles ( List < ApiImplementor > implementors ) throws IOException { for ( ApiImplementor implementor : implementors ) { this . generateAPIFiles ( implementor ) ; } } | Generates the API client files of the given API implementors . |
20,470 | public void setResponseBody ( HttpResponseBody resBody ) { if ( resBody == null ) { throw new IllegalArgumentException ( "The parameter resBody must not be null." ) ; } mResBody = resBody ; getResponseBody ( ) . setCharset ( getResponseHeader ( ) . getCharset ( ) ) ; } | Sets the response body of this message . |
20,471 | private static void validateFormatForViewAction ( Format format ) throws ApiException { switch ( format ) { case JSON : case JSONP : case XML : case HTML : return ; default : throw new ApiException ( ApiException . Type . BAD_FORMAT , "The format OTHER should not be used with views and actions." ) ; } } | Validates that the given format is supported for views and actions . |
20,472 | public void removeCallBackUrls ( ApiImplementor impl ) { if ( impl == null ) { throw new IllegalArgumentException ( "Parameter impl must not be null." ) ; } logger . debug ( "All callbacks removed for " + impl . getClass ( ) . getCanonicalName ( ) ) ; this . callBacks . values ( ) . removeIf ( impl :: equals ) ; } | Removes the given implementor as a callback handler . |
20,473 | public String getOneTimeNonce ( String apiUrl ) { String nonce = Long . toHexString ( random . nextLong ( ) ) ; this . nonces . put ( nonce , new Nonce ( nonce , apiUrl , true ) ) ; return nonce ; } | Returns a one time nonce to be used with the API call specified by the URL |
20,474 | public String getLongLivedNonce ( String apiUrl ) { String nonce = Long . toHexString ( random . nextLong ( ) ) ; this . nonces . put ( nonce , new Nonce ( nonce , apiUrl , false ) ) ; return nonce ; } | Returns a nonce that will be valid for the lifetime of the ZAP process to used with the API call specified by the URL |
20,475 | public void setLoggedInIndicatorPattern ( String loggedInIndicatorPattern ) { if ( loggedInIndicatorPattern == null || loggedInIndicatorPattern . trim ( ) . length ( ) == 0 ) { this . loggedInIndicatorPattern = null ; } else { this . loggedInIndicatorPattern = Pattern . compile ( loggedInIndicatorPattern ) ; } } | Sets the logged in indicator pattern . |
20,476 | public void setLoggedOutIndicatorPattern ( String loggedOutIndicatorPattern ) { if ( loggedOutIndicatorPattern == null || loggedOutIndicatorPattern . trim ( ) . length ( ) == 0 ) { this . loggedOutIndicatorPattern = null ; } else { this . loggedOutIndicatorPattern = Pattern . compile ( loggedOutIndicatorPattern ) ; } } | Sets the logged out indicator pattern . |
20,477 | public boolean isSameType ( AuthenticationMethod other ) { if ( other == null ) return false ; return other . getClass ( ) . equals ( this . getClass ( ) ) ; } | Checks if another method is of the same type . |
20,478 | private void showHiddenTabPopup ( ) { JPopupMenu menu = new JPopupMenu ( ) ; if ( getMousePosition ( ) == null ) { return ; } Collections . sort ( this . hiddenTabs , NAME_COMPARATOR ) ; for ( Component c : this . hiddenTabs ) { if ( c instanceof AbstractPanel ) { final AbstractPanel ap = ( AbstractPanel ) c ; JMenuItem mi = new JMenuItem ( ap . getName ( ) ) ; mi . setIcon ( ap . getIcon ( ) ) ; mi . addActionListener ( new ActionListener ( ) { public void actionPerformed ( ActionEvent e ) { setVisible ( ap , true ) ; ap . setTabFocus ( ) ; } } ) ; menu . add ( mi ) ; } } menu . show ( this , this . getMousePosition ( ) . x , this . getMousePosition ( ) . y ) ; } | Show a popup containing a list of all of the hidden tabs - selecting one will reveal that tab |
20,479 | public void removeTabAt ( int index ) { if ( index < 0 || index >= getTabCount ( ) ) { throw new IndexOutOfBoundsException ( "Index: " + index + ", Tab count: " + getTabCount ( ) ) ; } Component component = getComponentAt ( index ) ; super . removeTabAt ( index ) ; if ( ! ( component instanceof AbstractPanel ) ) { return ; } removeFromInternalState ( component ) ; } | Removes the tab at the given index and the corresponding panel . |
20,480 | public void setShowTabNames ( boolean showTabNames ) { for ( int i = 0 ; i < getTabCount ( ) ; i ++ ) { String title = showTabNames ? getComponentAt ( i ) . getName ( ) : "" ; setTitleAt ( i , title ) ; } } | Sets whether or not the tab names should be shown . |
20,481 | public final void setUndoManagerPolicy ( UndoManagerPolicy policy ) throws NullPointerException { if ( policy == null ) { throw new NullPointerException ( "The policy must not be null." ) ; } if ( this . policy == policy ) { return ; } final UndoManagerPolicy oldPolicy = this . policy ; this . policy = policy ; if ( oldPolicy == UndoManagerPolicy . DEFAULT ) { this . textComponent . removePropertyChangeListener ( "editable" , this ) ; this . textComponent . removePropertyChangeListener ( "enabled" , this ) ; } if ( this . policy == UndoManagerPolicy . DEFAULT ) { this . textComponent . addPropertyChangeListener ( "editable" , this ) ; this . textComponent . addPropertyChangeListener ( "enabled" , this ) ; } handleUndoManagerPolicy ( ) ; } | Sets the new policy . |
20,482 | public void addUser ( User user ) { this . users . add ( user ) ; this . fireTableRowsInserted ( this . users . size ( ) - 1 , this . users . size ( ) - 1 ) ; } | Adds a new user to this model |
20,483 | private JCheckBox getChkProxyOnly ( ) { if ( proxyOnlyCheckbox == null ) { proxyOnlyCheckbox = new JCheckBox ( ) ; proxyOnlyCheckbox . setText ( Constant . messages . getString ( "httpsessions.options.label.proxyOnly" ) ) ; } return proxyOnlyCheckbox ; } | Gets the chk proxy only . |
20,484 | private void initialize ( ) { this . setOrder ( EXTENSION_ORDER ) ; this . customParsers = new LinkedList < > ( ) ; this . customFetchFilters = new LinkedList < > ( ) ; this . customParseFilters = new LinkedList < > ( ) ; this . scanController = new SpiderScanController ( this ) ; } | This method initializes this extension . |
20,485 | public void startScanNode ( SiteNode node ) { Target target = new Target ( node ) ; target . setRecurse ( true ) ; this . startScan ( target , null , null ) ; } | Start scan node . |
20,486 | public void startScanAllInScope ( ) { Target target = new Target ( true ) ; target . setRecurse ( true ) ; this . startScan ( target , null , null ) ; } | Start scan all in scope . |
20,487 | public void startScan ( SiteNode startNode ) { Target target = new Target ( startNode ) ; target . setRecurse ( true ) ; this . startScan ( target , null , null ) ; } | Start scan . |
20,488 | public void startScanAllInContext ( Context context , User user ) { Target target = new Target ( context ) ; target . setRecurse ( true ) ; this . startScan ( target , user , null ) ; } | Start scan all in context from the POV of an User . |
20,489 | private String createDisplayName ( Target target , Object [ ] customConfigurations ) { HttpPrefixFetchFilter subtreeFecthFilter = getUriPrefixFecthFilter ( customConfigurations ) ; if ( subtreeFecthFilter != null ) { return abbreviateDisplayName ( subtreeFecthFilter . getNormalisedPrefix ( ) ) ; } if ( target . getContext ( ) != null ) { return Constant . messages . getString ( "context.prefixName" , target . getContext ( ) . getName ( ) ) ; } else if ( target . isInScopeOnly ( ) ) { return Constant . messages . getString ( "target.allInScope" ) ; } else if ( target . getStartNode ( ) == null ) { if ( customConfigurations != null ) { for ( Object customConfiguration : customConfigurations ) { if ( customConfiguration instanceof URI ) { return abbreviateDisplayName ( ( ( URI ) customConfiguration ) . toString ( ) ) ; } } } return Constant . messages . getString ( "target.empty" ) ; } return abbreviateDisplayName ( target . getStartNode ( ) . getHierarchicNodeName ( false ) ) ; } | Creates the display name for the given target and optionally the given custom configurations . |
20,490 | public void showSpiderDialog ( Target target ) { if ( spiderDialog == null ) { spiderDialog = new SpiderDialog ( this , View . getSingleton ( ) . getMainFrame ( ) , new Dimension ( 700 , 430 ) ) ; } if ( spiderDialog . isVisible ( ) ) { spiderDialog . toFront ( ) ; return ; } if ( target != null ) { spiderDialog . init ( target ) ; } else { spiderDialog . init ( null ) ; } spiderDialog . setVisible ( true ) ; } | Shows the spider dialogue with the given target if not already visible . |
20,491 | private JTable getTableFilter ( ) { if ( tableFilter == null ) { tableFilter = new JTable ( ) ; tableFilter . setRowHeight ( DisplayUtils . getScaledSize ( 18 ) ) ; tableFilter . setIntercellSpacing ( new java . awt . Dimension ( 1 , 1 ) ) ; tableFilter . setModel ( getAllFilterTableModel ( ) ) ; for ( int i = 0 ; i < width . length ; i ++ ) { TableColumn column = tableFilter . getColumnModel ( ) . getColumn ( i ) ; column . setPreferredWidth ( width [ i ] ) ; } TableColumn col = tableFilter . getColumnModel ( ) . getColumn ( 2 ) ; col . setCellRenderer ( new AllFilterTableRenderer ( ) ) ; col . setCellEditor ( new AllFilterTableEditor ( getAllFilterTableModel ( ) ) ) ; } return tableFilter ; } | This method initializes tableFilter |
20,492 | private JButton getBtnEnableAll ( ) { if ( btnEnableAll == null ) { btnEnableAll = new JButton ( ) ; btnEnableAll . setText ( Constant . messages . getString ( "filter.button.enableall" ) ) ; btnEnableAll . setEnabled ( false ) ; btnEnableAll . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { } } ) ; } return btnEnableAll ; } | This method initializes btnEnableAll |
20,493 | private JButton getBtnDisableAll ( ) { if ( btnDisableAll == null ) { btnDisableAll = new JButton ( ) ; btnDisableAll . setText ( Constant . messages . getString ( "filter.button.disableall" ) ) ; btnDisableAll . setEnabled ( false ) ; btnDisableAll . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { } } ) ; } return btnDisableAll ; } | This method initializes btnDisableAll |
20,494 | public void addPolicyPanel ( AbstractParamPanel panel ) { this . additionalPanels . add ( panel ) ; addParamPanel ( ROOT , panel . getName ( ) , panel , true ) ; } | Adds the given panel positioned under the root node and in alphabetic order . |
20,495 | public PolicyAllCategoryPanel getPolicyAllCategoryPanel ( ) { if ( policyAllCategoryPanel == null ) { policyAllCategoryPanel = new PolicyAllCategoryPanel ( this . pmd , extension , policy ) ; policyAllCategoryPanel . setName ( Constant . messages . getString ( "ascan.policy.title" ) ) ; } return policyAllCategoryPanel ; } | This method initializes policyAllCategoryPanel |
20,496 | private static byte [ ] makeRandomChallenge ( final Random random ) throws AuthenticationException { final byte [ ] rval = new byte [ 8 ] ; synchronized ( random ) { random . nextBytes ( rval ) ; } return rval ; } | Calculate a challenge block |
20,497 | private static byte [ ] makeSecondaryKey ( final Random random ) throws AuthenticationException { final byte [ ] rval = new byte [ 16 ] ; synchronized ( random ) { random . nextBytes ( rval ) ; } return rval ; } | Calculate a 16 - byte secondary key |
20,498 | static byte [ ] hmacMD5 ( final byte [ ] value , final byte [ ] key ) throws AuthenticationException { final HMACMD5 hmacMD5 = new HMACMD5 ( key ) ; hmacMD5 . update ( value ) ; return hmacMD5 . getOutput ( ) ; } | Calculates HMAC - MD5 |
20,499 | static byte [ ] ntlm2SessionResponse ( final byte [ ] ntlmHash , final byte [ ] challenge , final byte [ ] clientChallenge ) throws AuthenticationException { try { final MessageDigest md5 = getMD5 ( ) ; md5 . update ( challenge ) ; md5 . update ( clientChallenge ) ; final byte [ ] digest = md5 . digest ( ) ; final byte [ ] sessionHash = new byte [ 8 ] ; System . arraycopy ( digest , 0 , sessionHash , 0 , 8 ) ; return lmResponse ( ntlmHash , sessionHash ) ; } catch ( final Exception e ) { if ( e instanceof AuthenticationException ) { throw ( AuthenticationException ) e ; } throw new AuthenticationException ( e . getMessage ( ) , e ) ; } } | Calculates the NTLM2 Session Response for the given challenge using the specified password and client challenge . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.