idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
20,500 | private static byte [ ] lmResponse ( final byte [ ] hash , final byte [ ] challenge ) throws AuthenticationException { try { final byte [ ] keyBytes = new byte [ 21 ] ; System . arraycopy ( hash , 0 , keyBytes , 0 , 16 ) ; final Key lowKey = createDESKey ( keyBytes , 0 ) ; final Key middleKey = createDESKey ( keyBytes , 7 ) ; final Key highKey = createDESKey ( keyBytes , 14 ) ; final Cipher des = Cipher . getInstance ( "DES/ECB/NoPadding" ) ; des . init ( Cipher . ENCRYPT_MODE , lowKey ) ; final byte [ ] lowResponse = des . doFinal ( challenge ) ; des . init ( Cipher . ENCRYPT_MODE , middleKey ) ; final byte [ ] middleResponse = des . doFinal ( challenge ) ; des . init ( Cipher . ENCRYPT_MODE , highKey ) ; final byte [ ] highResponse = des . doFinal ( challenge ) ; final byte [ ] lmResponse = new byte [ 24 ] ; System . arraycopy ( lowResponse , 0 , lmResponse , 0 , 8 ) ; System . arraycopy ( middleResponse , 0 , lmResponse , 8 , 8 ) ; System . arraycopy ( highResponse , 0 , lmResponse , 16 , 8 ) ; return lmResponse ; } catch ( final Exception e ) { throw new AuthenticationException ( e . getMessage ( ) , e ) ; } } | Creates the LM Response from the given hash and Type 2 challenge . |
20,501 | private static byte [ ] createBlob ( final byte [ ] clientChallenge , final byte [ ] targetInformation , final byte [ ] timestamp ) { final byte [ ] blobSignature = new byte [ ] { ( byte ) 0x01 , ( byte ) 0x01 , ( byte ) 0x00 , ( byte ) 0x00 } ; final byte [ ] reserved = new byte [ ] { ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 } ; final byte [ ] unknown1 = new byte [ ] { ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 } ; final byte [ ] unknown2 = new byte [ ] { ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 } ; final byte [ ] blob = new byte [ blobSignature . length + reserved . length + timestamp . length + 8 + unknown1 . length + targetInformation . length + unknown2 . length ] ; int offset = 0 ; System . arraycopy ( blobSignature , 0 , blob , offset , blobSignature . length ) ; offset += blobSignature . length ; System . arraycopy ( reserved , 0 , blob , offset , reserved . length ) ; offset += reserved . length ; System . arraycopy ( timestamp , 0 , blob , offset , timestamp . length ) ; offset += timestamp . length ; System . arraycopy ( clientChallenge , 0 , blob , offset , 8 ) ; offset += 8 ; System . arraycopy ( unknown1 , 0 , blob , offset , unknown1 . length ) ; offset += unknown1 . length ; System . arraycopy ( targetInformation , 0 , blob , offset , targetInformation . length ) ; offset += targetInformation . length ; System . arraycopy ( unknown2 , 0 , blob , offset , unknown2 . length ) ; offset += unknown2 . length ; return blob ; } | Creates the NTLMv2 blob from the given target information block and client challenge . |
20,502 | private static Key createDESKey ( final byte [ ] bytes , final int offset ) { final byte [ ] keyBytes = new byte [ 7 ] ; System . arraycopy ( bytes , offset , keyBytes , 0 , 7 ) ; final byte [ ] material = new byte [ 8 ] ; material [ 0 ] = keyBytes [ 0 ] ; material [ 1 ] = ( byte ) ( keyBytes [ 0 ] << 7 | ( keyBytes [ 1 ] & 0xff ) >>> 1 ) ; material [ 2 ] = ( byte ) ( keyBytes [ 1 ] << 6 | ( keyBytes [ 2 ] & 0xff ) >>> 2 ) ; material [ 3 ] = ( byte ) ( keyBytes [ 2 ] << 5 | ( keyBytes [ 3 ] & 0xff ) >>> 3 ) ; material [ 4 ] = ( byte ) ( keyBytes [ 3 ] << 4 | ( keyBytes [ 4 ] & 0xff ) >>> 4 ) ; material [ 5 ] = ( byte ) ( keyBytes [ 4 ] << 3 | ( keyBytes [ 5 ] & 0xff ) >>> 5 ) ; material [ 6 ] = ( byte ) ( keyBytes [ 5 ] << 2 | ( keyBytes [ 6 ] & 0xff ) >>> 6 ) ; material [ 7 ] = ( byte ) ( keyBytes [ 6 ] << 1 ) ; oddParity ( material ) ; return new SecretKeySpec ( material , "DES" ) ; } | Creates a DES encryption key from the given key material . |
20,503 | private static Charset getCharset ( final int flags ) throws AuthenticationException { if ( ( flags & FLAG_REQUEST_UNICODE_ENCODING ) == 0 ) { return DEFAULT_CHARSET ; } else { if ( UNICODE_LITTLE_UNMARKED == null ) { throw new AuthenticationException ( "Unicode not supported" ) ; } return UNICODE_LITTLE_UNMARKED ; } } | Find the character set based on the flags . |
20,504 | private static String stripDotSuffix ( final String value ) { if ( value == null ) { return null ; } final int index = value . indexOf ( "." ) ; if ( index != - 1 ) { return value . substring ( 0 , index ) ; } return value ; } | Strip dot suffix from a name |
20,505 | public static Font getFont ( String name , int style ) { return new Font ( name , style , getDefaultFont ( ) . getSize ( ) ) ; } | Gets the named font with the specified style correctly scaled |
20,506 | public static Font getFont ( int style , Size size ) { return getFont ( getDefaultFont ( ) , size ) . deriveFont ( style ) ; } | Gets the default font with the specified style and size correctly scaled |
20,507 | public static Font getFont ( Font font , int style , Size size ) { return getFont ( font , size ) . deriveFont ( style ) ; } | Gets the specified font with the specified style and size correctly scaled |
20,508 | public static Font getFont ( Font font , Size size ) { float s ; switch ( size ) { case smallest : s = ( float ) ( font . getSize ( ) * 0.5 ) ; break ; case much_smaller : s = ( float ) ( font . getSize ( ) * 0.7 ) ; break ; case smaller : s = ( float ) ( font . getSize ( ) * 0.8 ) ; break ; case standard : s = ( float ) font . getSize ( ) ; break ; case larger : s = ( float ) ( font . getSize ( ) * 1.5 ) ; break ; case much_larger : s = ( float ) ( font . getSize ( ) * 3 ) ; break ; case huge : s = ( float ) ( font . getSize ( ) * 4 ) ; break ; default : s = ( float ) ( font . getSize ( ) ) ; break ; } return font . deriveFont ( s ) ; } | Gets the specified font with the specified size correctly scaled |
20,509 | public Object getValueAt ( int row , int col ) { HistoryReference href = hrefList . get ( row ) ; try { switch ( this . columns [ col ] ) { case HREF_ID : return href . getHistoryId ( ) ; case TYPE_FLAG : return this . getHrefTypeIcon ( href ) ; case METHOD : return href . getMethod ( ) ; case URL : return href . getURI ( ) . toString ( ) ; case CODE : return href . getStatusCode ( ) ; case REASON : return href . getReason ( ) ; case RTT : return href . getRtt ( ) ; case SIZE : return href . getResponseBodyLength ( ) ; case SESSION_ID : return href . getSessionId ( ) ; case ALERT_FLAG : return this . getHrefAlertIcon ( href ) ; case TAGS : return listToCsv ( href . getTags ( ) ) ; default : return null ; } } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; return null ; } } | This should be overriden for any custom columns |
20,510 | public void add ( HistoryReference href ) { synchronized ( hrefList ) { hrefList . add ( href ) ; fireTableRowsInserted ( hrefList . size ( ) - 1 , hrefList . size ( ) - 1 ) ; } } | Adds a href . Method is synchronized internally . |
20,511 | public Class < ? > getColumnClass ( int columnIndex ) { switch ( this . columns [ columnIndex ] ) { case HREF_ID : return Integer . class ; case TYPE_FLAG : return ImageIcon . class ; case METHOD : return String . class ; case URL : return String . class ; case CODE : return Integer . class ; case REASON : return String . class ; case RTT : return Integer . class ; case SIZE : return Integer . class ; case SESSION_ID : return Long . class ; case ALERT_FLAG : return ImageIcon . class ; case TAGS : return String . class ; default : return null ; } } | Returns the type of column for given column index . This should be overriden for any custom columns |
20,512 | public void removeAllElements ( ) { if ( View . isInitialised ( ) && ! EventQueue . isDispatchThread ( ) ) { EventQueue . invokeLater ( new Runnable ( ) { public void run ( ) { removeAllElements ( ) ; } } ) ; return ; } sessions . clear ( ) ; sessions . trimToSize ( ) ; fireTableDataChanged ( ) ; } | Removes all the elements . |
20,513 | public void addHttpSession ( final HttpSession session ) { if ( View . isInitialised ( ) && ! EventQueue . isDispatchThread ( ) ) { EventQueue . invokeLater ( new Runnable ( ) { public void run ( ) { addHttpSession ( session ) ; } } ) ; return ; } if ( sessions . contains ( session ) ) return ; sessions . add ( session ) ; final int affectedRow = sessions . size ( ) - 1 ; fireTableRowsInserted ( affectedRow , affectedRow ) ; } | Adds a new http session to the model . |
20,514 | public Class < ? > getColumnClass ( int columnIndex ) { switch ( columnIndex ) { case 0 : return Boolean . class ; case 1 : return String . class ; case 2 : return String . class ; case 3 : return Integer . class ; } return null ; } | Returns the type of column for given column index . |
20,515 | protected HttpSession getHttpSessionAt ( int rowIndex ) { if ( rowIndex < 0 || rowIndex >= sessions . size ( ) ) return null ; return sessions . get ( rowIndex ) ; } | Gets the http session at a particular row index . |
20,516 | public void removeHttpSession ( final HttpSession session ) { if ( View . isInitialised ( ) && ! EventQueue . isDispatchThread ( ) ) { EventQueue . invokeLater ( new Runnable ( ) { public void run ( ) { removeHttpSession ( session ) ; } } ) ; return ; } int index = sessions . indexOf ( session ) ; sessions . remove ( index ) ; fireTableRowsDeleted ( index , index ) ; } | Removes the http session . |
20,517 | public void fireHttpSessionUpdated ( final HttpSession session ) { if ( View . isInitialised ( ) && ! EventQueue . isDispatchThread ( ) ) { EventQueue . invokeLater ( new Runnable ( ) { public void run ( ) { fireHttpSessionUpdated ( session ) ; } } ) ; return ; } int index = sessions . indexOf ( session ) ; fireTableRowsUpdated ( index , index ) ; } | Notifies the model that a http session has been updated . |
20,518 | public void update ( List < UninstallationProgressEvent > events ) { if ( ! isVisible ( ) ) { if ( ( System . currentTimeMillis ( ) - startTime ) >= MS_TO_WAIT_BEFORE_SHOW ) { if ( ! done && ! setVisibleInvoked ) { setVisibleInvoked = true ; EventQueue . invokeLater ( new Runnable ( ) { public void run ( ) { if ( ! done ) { UninstallationProgressDialogue . super . setVisible ( true ) ; } } } ) ; } } } int totalAmount = 0 ; AddOn addOn = null ; for ( UninstallationProgressEvent event : events ) { totalAmount += event . getAmount ( ) ; if ( UninstallationProgressEvent . Type . FINISHED_ADD_ON == event . getType ( ) ) { for ( AddOnUninstallListener listener : listeners ) { failedUninstallations = ! event . isUninstalled ( ) ; listener . addOnUninstalled ( currentAddOn , update , event . isUninstalled ( ) ) ; } } else if ( UninstallationProgressEvent . Type . ADD_ON == event . getType ( ) ) { addOn = event . getAddOn ( ) ; currentAddOn = addOn ; update = event . isUpdate ( ) ; for ( AddOnUninstallListener listener : listeners ) { listener . uninstallingAddOn ( addOn , update ) ; } } } UninstallationProgressEvent last = events . get ( events . size ( ) - 1 ) ; if ( addOn != null ) { setCurrentAddOn ( addOn ) ; } if ( totalAmount != 0 ) { incrementProgress ( totalAmount ) ; } if ( currentType != last . getType ( ) ) { String keyMessage ; switch ( last . getType ( ) ) { case FILE : keyMessage = "cfu.uninstallation.progress.dialogue.uninstallingFile" ; break ; case ACTIVE_RULE : keyMessage = "cfu.uninstallation.progress.dialogue.uninstallingActiveScanner" ; break ; case PASSIVE_RULE : keyMessage = "cfu.uninstallation.progress.dialogue.uninstallingPassiveScanner" ; break ; case EXTENSION : keyMessage = "cfu.uninstallation.progress.dialogue.uninstallingExtension" ; break ; default : keyMessage = "" ; break ; } currentType = last . getType ( ) ; keyBaseStatusMessage = keyMessage ; } if ( keyBaseStatusMessage . isEmpty ( ) ) { setCustomMessage ( "" ) ; } else { setCustomMessage ( Constant . messages . getString ( keyBaseStatusMessage , last . getValue ( ) , last . getMax ( ) ) ) ; } } | Updates the progress with the given events . |
20,519 | private static void validateKey ( String key ) { if ( key == null || key . length ( ) > MAX_KEY_SIZE ) { throw new IllegalArgumentException ( "Invalid key - must be non null and have a length less than " + MAX_KEY_SIZE ) ; } } | Validates the given key . |
20,520 | private static String getScriptName ( ScriptContext context ) { if ( context == null ) { throw new IllegalArgumentException ( "Invalid context - must be non null" ) ; } Object scriptName = context . getAttribute ( ExtensionScript . SCRIPT_NAME_ATT ) ; if ( scriptName == null ) { throw new IllegalArgumentException ( "Failed to find script name in the script context." ) ; } if ( ! ( scriptName instanceof String ) ) { throw new IllegalArgumentException ( "The script name is not a String: " + scriptName . getClass ( ) . getCanonicalName ( ) ) ; } return ( String ) scriptName ; } | Gets the script name from the given context . |
20,521 | private static void setScriptVarImpl ( String scriptName , String key , String value ) { validateKey ( key ) ; Map < String , String > scVars = scriptVars . computeIfAbsent ( scriptName , k -> Collections . synchronizedMap ( new HashMap < String , String > ( ) ) ) ; if ( value == null ) { scVars . remove ( key ) ; } else { validateValueLength ( value ) ; if ( scVars . size ( ) > MAX_SCRIPT_VARS ) { throw new IllegalArgumentException ( "Maximum number of script variables reached: " + MAX_SCRIPT_VARS ) ; } scVars . put ( key , value ) ; } } | Internal method that sets a variable without validating the script name . |
20,522 | public static String getScriptVar ( ScriptContext context , String key ) { return getScriptVarImpl ( getScriptName ( context ) , key ) ; } | Gets a script variable . |
20,523 | public static String getScriptVar ( String scriptName , String key ) { validateScriptName ( scriptName ) ; return getScriptVarImpl ( scriptName , key ) ; } | Gets a variable from the script with the given name . |
20,524 | private static String getScriptVarImpl ( String scriptName , String key ) { Map < String , String > scVars = scriptVars . get ( scriptName ) ; if ( scVars == null ) { return null ; } return scVars . get ( key ) ; } | Internal method that gets a variable without validating the script name . |
20,525 | public HttpMethod createRequestMethodNew ( HttpRequestHeader header , HttpBody body ) throws URIException { HttpMethod httpMethod = null ; String method = header . getMethod ( ) ; URI uri = header . getURI ( ) ; String version = header . getVersion ( ) ; httpMethod = new GenericMethod ( method ) ; httpMethod . setURI ( uri ) ; HttpMethodParams httpParams = httpMethod . getParams ( ) ; httpParams . setVersion ( HttpVersion . HTTP_1_0 ) ; if ( version . equalsIgnoreCase ( HttpHeader . HTTP11 ) ) { httpParams . setVersion ( HttpVersion . HTTP_1_1 ) ; } int pos = 0 ; Pattern pattern = patternCRLF ; String msg = header . getHeadersAsString ( ) ; if ( ( pos = msg . indexOf ( CRLF ) ) < 0 ) { if ( ( pos = msg . indexOf ( LF ) ) < 0 ) { pattern = patternLF ; } } else { pattern = patternCRLF ; } String [ ] split = pattern . split ( msg ) ; String token = null ; String name = null ; String value = null ; for ( int i = 0 ; i < split . length ; i ++ ) { token = split [ i ] ; if ( token . equals ( "" ) ) { continue ; } if ( ( pos = token . indexOf ( ":" ) ) < 0 ) { return null ; } name = token . substring ( 0 , pos ) . trim ( ) ; value = token . substring ( pos + 1 ) . trim ( ) ; httpMethod . addRequestHeader ( name , value ) ; } if ( body != null && body . length ( ) > 0 ) { EntityEnclosingMethod generic = ( EntityEnclosingMethod ) httpMethod ; generic . setRequestEntity ( new ByteArrayRequestEntity ( body . getBytes ( ) ) ) ; } httpMethod . setFollowRedirects ( false ) ; return httpMethod ; } | Not used - all abstract using Generic method but GET cannot be used . |
20,526 | public HttpMethod createRequestMethod ( HttpRequestHeader header , HttpBody body ) throws URIException { return createRequestMethod ( header , body , null ) ; } | may be replaced by the New method - however the New method is not yet fully tested so this is stil used . |
20,527 | private JPanel getPaneContent ( ) { if ( paneContent == null ) { paneContent = new JPanel ( ) ; paneContent . setLayout ( new BoxLayout ( getPaneContent ( ) , BoxLayout . Y_AXIS ) ) ; paneContent . setEnabled ( true ) ; paneContent . add ( getMainToolbarPanel ( ) , null ) ; paneContent . add ( getPaneDisplay ( ) , null ) ; paneContent . add ( getMainFooterPanel ( ) , null ) ; } return paneContent ; } | This method initializes paneContent |
20,528 | public org . parosproxy . paros . view . MainMenuBar getMainMenuBar ( ) { if ( mainMenuBar == null ) { mainMenuBar = new org . parosproxy . paros . view . MainMenuBar ( ) ; } return mainMenuBar ; } | This method initializes mainMenuBar |
20,529 | public JPanel getPaneDisplay ( ) { if ( paneDisplay == null ) { paneDisplay = new JPanel ( ) ; paneDisplay . setLayout ( new CardLayout ( ) ) ; paneDisplay . setName ( "paneDisplay" ) ; paneDisplay . add ( getWorkbench ( ) , getWorkbench ( ) . getName ( ) ) ; } return paneDisplay ; } | This method initializes paneDisplay |
20,530 | private ZapMenuItem getMenuFind ( ) { if ( menuFind == null ) { menuFind = new ZapMenuItem ( "menu.edit.find" , getFindDefaultKeyStroke ( ) ) ; menuFind . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { showFindDialog ( getView ( ) . getMainFrame ( ) , null ) ; } } ) ; } return menuFind ; } | This method initializes menuFind |
20,531 | private PopupFindMenu getPopupMenuFind ( ) { if ( popupFindMenu == null ) { popupFindMenu = new PopupFindMenu ( ) ; popupFindMenu . setText ( Constant . messages . getString ( "edit.find.popup" ) ) ; popupFindMenu . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { JTextComponent component = popupFindMenu . getLastInvoker ( ) ; Window window = getWindowAncestor ( component ) ; if ( window != null ) { showFindDialog ( window , component ) ; } } } ) ; } return popupFindMenu ; } | This method initializes popupMenuFind |
20,532 | public static ImageIcon getScaledIcon ( URL url ) { if ( url == null ) { return null ; } return getScaledIcon ( new ImageIcon ( url ) ) ; } | Gets a correctly scaled icon from the specified url |
20,533 | public static Insets getScaledInsets ( int top , int left , int bottom , int right ) { if ( FontUtils . getScale ( ) == 1 ) { return new Insets ( top , left , bottom , right ) ; } return new Insets ( ( int ) ( top * FontUtils . getScale ( ) ) , ( int ) ( left * FontUtils . getScale ( ) ) , ( int ) ( bottom * FontUtils . getScale ( ) ) , ( int ) ( right * FontUtils . getScale ( ) ) ) ; } | Gets correctly scaled Insets |
20,534 | private void initialize ( ) { this . setLayout ( new CardLayout ( ) ) ; this . setName ( Constant . messages . getString ( "spider.options.title" ) ) ; if ( Model . getSingleton ( ) . getOptionsParam ( ) . getViewParam ( ) . getWmUiHandlingOption ( ) == 0 ) { this . setSize ( 314 , 245 ) ; } this . add ( getPanelSpider ( ) , getPanelSpider ( ) . getName ( ) ) ; } | This method initializes this options Panel . |
20,535 | private JSlider getSliderMaxDepth ( ) { if ( sliderMaxDepth == null ) { sliderMaxDepth = new JSlider ( ) ; sliderMaxDepth . setMaximum ( 19 ) ; sliderMaxDepth . setMinimum ( 0 ) ; sliderMaxDepth . setMinorTickSpacing ( 1 ) ; sliderMaxDepth . setPaintTicks ( true ) ; sliderMaxDepth . setPaintLabels ( true ) ; sliderMaxDepth . setName ( "" ) ; sliderMaxDepth . setMajorTickSpacing ( 1 ) ; sliderMaxDepth . setSnapToTicks ( true ) ; sliderMaxDepth . setPaintTrack ( true ) ; } return sliderMaxDepth ; } | This method initializes the slider for MaxDepth . |
20,536 | private JCheckBox getChkPostForm ( ) { if ( chkPostForm == null ) { chkPostForm = new JCheckBox ( ) ; chkPostForm . setText ( Constant . messages . getString ( "spider.options.label.post" ) ) ; if ( ! getChkProcessForm ( ) . isSelected ( ) ) { chkPostForm . setEnabled ( false ) ; } } return chkPostForm ; } | This method initializes the checkbox for POST form option . This option should not be enabled if the forms are not processed at all . |
20,537 | private JCheckBox getChkProcessForm ( ) { if ( chkProcessForm == null ) { chkProcessForm = new JCheckBox ( ) ; chkProcessForm . setText ( Constant . messages . getString ( "spider.options.label.processform" ) ) ; chkProcessForm . addChangeListener ( new ChangeListener ( ) { public void stateChanged ( ChangeEvent ev ) { if ( chkProcessForm . isSelected ( ) ) { chkPostForm . setEnabled ( true ) ; } else { chkPostForm . setEnabled ( false ) ; } } } ) ; } return chkProcessForm ; } | This method initializes the checkbox for process form option . |
20,538 | private JCheckBox getChkParseComments ( ) { if ( parseComments == null ) { parseComments = new JCheckBox ( ) ; parseComments . setText ( Constant . messages . getString ( "spider.options.label.comments" ) ) ; } return parseComments ; } | This method initializes the Parse Comments checkbox . |
20,539 | private JCheckBox getChkParseRobotsTxt ( ) { if ( parseRobotsTxt == null ) { parseRobotsTxt = new JCheckBox ( ) ; parseRobotsTxt . setText ( Constant . messages . getString ( "spider.options.label.robotstxt" ) ) ; } return parseRobotsTxt ; } | This method initializes the Parse robots . txt checkbox . |
20,540 | private JCheckBox getChkParseSitemapXml ( ) { if ( parseSitemapXml == null ) { parseSitemapXml = new JCheckBox ( ) ; parseSitemapXml . setText ( Constant . messages . getString ( "spider.options.label.sitemapxml" ) ) ; } return parseSitemapXml ; } | This method initializes the Parse sitemap . xml checkbox . |
20,541 | private JCheckBox getChkParseSVNEntries ( ) { if ( parseSVNEntries == null ) { parseSVNEntries = new JCheckBox ( ) ; parseSVNEntries . setText ( Constant . messages . getString ( "spider.options.label.svnentries" ) ) ; } return parseSVNEntries ; } | This method initializes the Parse SVN Entries checkbox . |
20,542 | private JCheckBox getChkParseGit ( ) { if ( parseGit == null ) { parseGit = new JCheckBox ( ) ; parseGit . setText ( Constant . messages . getString ( "spider.options.label.git" ) ) ; } return parseGit ; } | This method initializes the Parse Git checkbox . |
20,543 | private JCheckBox getHandleODataSpecificParameters ( ) { if ( handleODataSpecificParameters == null ) { handleODataSpecificParameters = new JCheckBox ( ) ; handleODataSpecificParameters . setText ( Constant . messages . getString ( "spider.options.label.handlehodataparameters" ) ) ; } return handleODataSpecificParameters ; } | This method initializes the Handle OData - specific parameters checkbox . |
20,544 | @ SuppressWarnings ( "unchecked" ) private JComboBox < HandleParametersOption > getComboHandleParameters ( ) { if ( handleParameters == null ) { handleParameters = new JComboBox < > ( new HandleParametersOption [ ] { HandleParametersOption . USE_ALL , HandleParametersOption . IGNORE_VALUE , HandleParametersOption . IGNORE_COMPLETELY } ) ; handleParameters . setRenderer ( new HandleParametersOptionRenderer ( ) ) ; } return handleParameters ; } | This method initializes the combobox for HandleParameters option . |
20,545 | void loadScript ( Charset charset ) throws IOException { this . charset = charset ; StringBuilder sb = new StringBuilder ( ) ; try ( BufferedReader br = Files . newBufferedReader ( file . toPath ( ) , charset ) ) { int len ; char [ ] buf = new char [ 1024 ] ; while ( ( len = br . read ( buf ) ) != - 1 ) { sb . append ( buf , 0 , len ) ; } } setContents ( sb . toString ( ) ) ; setChanged ( false ) ; this . lastModified = file . lastModified ( ) ; } | Loads the script from the configured file . |
20,546 | void saveScript ( ) throws IOException { this . charset = ExtensionScript . DEFAULT_CHARSET ; try ( BufferedWriter bw = Files . newBufferedWriter ( file . toPath ( ) , charset ) ) { bw . append ( getContents ( ) ) ; } this . lastModified = file . lastModified ( ) ; } | Saves the latest contents into the configured file |
20,547 | public void reset ( ) { table . getColumnModel ( ) . removeColumnModelListener ( this ) ; columnModel = table . getColumnModel ( ) ; columnModel . addColumnModelListener ( this ) ; int count = columnModel . getColumnCount ( ) ; allColumns = new ArrayList < > ( count ) ; for ( int i = 0 ; i < count ; i ++ ) { allColumns . add ( columnModel . getColumn ( i ) ) ; } } | Reset the TableColumnManager to only manage the TableColumns that are currently visible in the table . |
20,548 | private void showColumn ( TableColumn column ) { columnModel . removeColumnModelListener ( this ) ; columnModel . addColumn ( column ) ; int position = allColumns . indexOf ( column ) ; int from = columnModel . getColumnCount ( ) - 1 ; int to = 0 ; for ( int i = position - 1 ; i > - 1 ; i -- ) { try { TableColumn visibleColumn = allColumns . get ( i ) ; to = columnModel . getColumnIndex ( visibleColumn . getHeaderValue ( ) ) + 1 ; break ; } catch ( IllegalArgumentException e ) { } } columnModel . moveColumn ( from , to ) ; columnModel . addColumnModelListener ( this ) ; } | Show a hidden column in the table . The column will be positioned at its proper place in the view of the table . |
20,549 | public static HarCustomFields createMessageHarCustomFields ( int historyId , int historyType , String messageNote ) { HarCustomFields customFields = new HarCustomFields ( ) ; customFields . addCustomField ( MESSAGE_ID_CUSTOM_FIELD , Integer . toString ( historyId ) ) ; customFields . addCustomField ( MESSAGE_TYPE_CUSTOM_FIELD , Integer . toString ( historyType ) ) ; customFields . addCustomField ( MESSAGE_NOTE_CUSTOM_FIELD , messageNote ) ; return customFields ; } | Creates custom fields for the given data . |
20,550 | public void setMessage ( String data ) throws HttpMalformedHeaderException { clear ( ) ; try { if ( ! this . parse ( data ) ) { mMalformedHeader = true ; } } catch ( Exception e ) { mMalformedHeader = true ; } if ( mMalformedHeader ) { throw new HttpMalformedHeaderException ( ) ; } } | Set and parse this HTTP header with the string given . |
20,551 | public String getHeader ( String name ) { Vector < String > v = getHeaders ( name ) ; if ( v == null ) { return null ; } return v . firstElement ( ) ; } | Get the first header value using the name given . If there are multiple occurrence only the first one will be returned as String . |
20,552 | public void addHeader ( String name , String val ) { mMsgHeader = mMsgHeader + name + ": " + val + mLineDelimiter ; addInternalHeaderFields ( name , val ) ; } | Add a header with the name and value given . It will be appended to the header string . |
20,553 | public void setHeader ( String name , String value ) { Pattern pattern = null ; if ( getHeaders ( name ) == null && value != null ) { addHeader ( name , value ) ; } else { pattern = getHeaderRegex ( name ) ; Matcher matcher = pattern . matcher ( mMsgHeader ) ; if ( value == null ) { mMsgHeader = matcher . replaceAll ( "" ) ; } else { String newString = name + ": " + value + mLineDelimiter ; mMsgHeader = matcher . replaceAll ( Matcher . quoteReplacement ( newString ) ) ; } replaceInternalHeaderFields ( name , value ) ; } } | Set a header name and value . If the name is not found it will be added . If the value is null the header will be removed . |
20,554 | public void setContentLength ( int len ) { if ( mContentLength != len ) { setHeader ( CONTENT_LENGTH , Integer . toString ( len ) ) ; mContentLength = len ; } } | Set the content length of this header . |
20,555 | public boolean isTransferEncodingChunked ( ) { String transferEncoding = getHeader ( TRANSFER_ENCODING ) ; if ( transferEncoding != null && transferEncoding . equalsIgnoreCase ( _CHUNKED ) ) { return true ; } return false ; } | Check if Transfer Encoding Chunked is set in this header . |
20,556 | protected boolean parse ( String data ) throws Exception { if ( data == null || data . isEmpty ( ) ) { return true ; } String newData = data . replaceAll ( "(?<!\r)\n" , CRLF ) ; mLineDelimiter = CRLF ; String [ ] split = patternCRLF . split ( newData ) ; mStartLine = split [ 0 ] ; String token = null , name = null , value = null ; int pos = 0 ; StringBuilder sb = new StringBuilder ( 2048 ) ; for ( int i = 1 ; i < split . length ; i ++ ) { token = split [ i ] ; if ( token . equals ( "" ) ) { continue ; } if ( ( pos = token . indexOf ( ":" ) ) < 0 ) { mMalformedHeader = true ; return false ; } name = token . substring ( 0 , pos ) . trim ( ) ; value = token . substring ( pos + 1 ) . trim ( ) ; if ( name . equalsIgnoreCase ( CONTENT_LENGTH ) ) { try { mContentLength = Integer . parseInt ( value ) ; } catch ( NumberFormatException nfe ) { } } sb . append ( name + ": " + value + mLineDelimiter ) ; addInternalHeaderFields ( name , value ) ; } mMsgHeader = sb . toString ( ) ; return true ; } | Parse this Http header using the String given . |
20,557 | private void addInternalHeaderFields ( String name , String value ) { String key = normalisedHeaderName ( name ) ; Vector < String > v = getHeaders ( key ) ; if ( v == null ) { v = new Vector < > ( ) ; mHeaderFields . put ( key , v ) ; } if ( value != null ) { v . add ( value ) ; } else { mHeaderFields . remove ( key ) ; } } | Add the header stored in internal hashtable |
20,558 | public FetchStatus checkFilter ( URI uri ) { if ( uri == null ) { return FetchStatus . OUT_OF_SCOPE ; } String otherScheme = normalisedScheme ( uri . getRawScheme ( ) ) ; if ( port != normalisedPort ( otherScheme , uri . getPort ( ) ) ) { return FetchStatus . OUT_OF_SCOPE ; } if ( ! scheme . equals ( otherScheme ) ) { return FetchStatus . OUT_OF_SCOPE ; } if ( ! hasSameHost ( uri ) ) { return FetchStatus . OUT_OF_SCOPE ; } if ( ! startsWith ( uri . getRawPath ( ) , path ) ) { return FetchStatus . OUT_OF_SCOPE ; } return FetchStatus . VALID ; } | Filters any URI that does not start with the defined prefix . |
20,559 | private String getElapsedTimeLabel ( long elapsed ) { return ( elapsed >= 0 ) ? String . format ( "%02d:%02d.%03d" , elapsed / 60000 , ( elapsed % 60000 ) / 1000 , ( elapsed % 1000 ) ) : null ; } | Inner method for elapsed time label formatting |
20,560 | protected void save ( final String fileName , final SessionListener callback ) { Thread t = new Thread ( new Runnable ( ) { public void run ( ) { Exception thrownException = null ; try { save ( fileName ) ; } catch ( Exception e ) { log . warn ( e . getMessage ( ) , e ) ; thrownException = e ; } if ( callback != null ) { callback . sessionSaved ( thrownException ) ; } } } ) ; t . setPriority ( Thread . NORM_PRIORITY - 2 ) ; t . start ( ) ; } | Asynchronous call to save a session . |
20,561 | protected void save ( String fileName ) throws Exception { configuration . save ( new File ( fileName ) ) ; if ( isNewState ( ) ) { model . moveSessionDb ( fileName ) ; } else { if ( ! this . fileName . equals ( fileName ) ) { model . copySessionDb ( this . fileName , fileName ) ; } } this . fileName = fileName ; if ( ! Constant . isLowMemoryOptionSet ( ) ) { synchronized ( siteTree ) { saveSiteTree ( siteTree . getRoot ( ) ) ; } } model . getDb ( ) . getTableSession ( ) . update ( getSessionId ( ) , getSessionName ( ) ) ; } | Synchronous call to save a session . |
20,562 | protected void snapshot ( String fileName ) throws Exception { configuration . save ( new File ( fileName ) ) ; model . snapshotSessionDb ( this . fileName , fileName ) ; } | Synchronous call to snapshot a session . |
20,563 | public List < SiteNode > getTopNodesInScopeFromSiteTree ( ) { List < SiteNode > nodes = new LinkedList < > ( ) ; SiteNode rootNode = getSiteTree ( ) . getRoot ( ) ; @ SuppressWarnings ( "unchecked" ) Enumeration < TreeNode > en = rootNode . children ( ) ; while ( en . hasMoreElements ( ) ) { SiteNode sn = ( SiteNode ) en . nextElement ( ) ; if ( isContainsNodesInScope ( sn ) ) { nodes . add ( sn ) ; } } return nodes ; } | Gets the top nodes from the site tree which contain nodes that are In Scope . Searches recursively starting from the root node . Should be used with care as it is time - consuming querying the database for every node in the Site Tree . |
20,564 | public List < SiteNode > getNodesInContextFromSiteTree ( Context context ) { List < SiteNode > nodes = new LinkedList < > ( ) ; SiteNode rootNode = getSiteTree ( ) . getRoot ( ) ; fillNodesInContext ( rootNode , nodes , context ) ; return nodes ; } | Gets the nodes from the site tree which are In Scope in a given context . Searches recursively starting from the root node . Should be used with care as it is time - consuming querying the database for every node in the Site Tree . |
20,565 | private Context createContext ( String name ) { Context context = new Context ( this , this . nextContextIndex ++ ) ; context . setName ( name ) ; return context ; } | Creates a new context with the given name . |
20,566 | public void addContext ( Context c ) { if ( c == null ) { throw new IllegalArgumentException ( "The context must not be null. " ) ; } validateContextName ( c . getName ( ) ) ; this . contexts . add ( c ) ; this . model . loadContext ( c ) ; for ( OnContextsChangedListener l : contextsChangedListeners ) { l . contextAdded ( c ) ; } if ( View . isInitialised ( ) ) { View . getSingleton ( ) . addContext ( c ) ; } } | Adds the given context . |
20,567 | public void exportContext ( Context c , File file ) throws ConfigurationException { ZapXmlConfiguration config = new ZapXmlConfiguration ( ) ; config . setProperty ( Context . CONTEXT_CONFIG_NAME , c . getName ( ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_DESC , c . getDescription ( ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_INSCOPE , c . isInScope ( ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_INC_REGEXES , c . getIncludeInContextRegexs ( ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_EXC_REGEXES , c . getExcludeFromContextRegexs ( ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_TECH_INCLUDE , techListToStringList ( c . getTechSet ( ) . getIncludeTech ( ) ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_TECH_EXCLUDE , techListToStringList ( c . getTechSet ( ) . getExcludeTech ( ) ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_URLPARSER_CLASS , c . getUrlParamParser ( ) . getClass ( ) . getCanonicalName ( ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_URLPARSER_CONFIG , c . getUrlParamParser ( ) . getConfig ( ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_POSTPARSER_CLASS , c . getPostParamParser ( ) . getClass ( ) . getCanonicalName ( ) ) ; config . setProperty ( Context . CONTEXT_CONFIG_POSTPARSER_CONFIG , c . getPostParamParser ( ) . getConfig ( ) ) ; for ( StructuralNodeModifier snm : c . getDataDrivenNodes ( ) ) { config . addProperty ( Context . CONTEXT_CONFIG_DATA_DRIVEN_NODES , snm . getConfig ( ) ) ; } model . exportContext ( c , config ) ; config . save ( file ) ; } | Export the specified context to a file |
20,568 | public ParameterParser getUrlParamParser ( String url ) { List < Context > contexts = getContextsForUrl ( url ) ; if ( contexts . size ( ) > 0 ) { return contexts . get ( 0 ) . getUrlParamParser ( ) ; } return this . defaultParamParser ; } | Returns the url parameter parser associated with the first context found that includes the URL or the default parser if it is not in a context |
20,569 | public ParameterParser getFormParamParser ( String url ) { List < Context > contexts = getContextsForUrl ( url ) ; if ( contexts . size ( ) > 0 ) { return contexts . get ( 0 ) . getPostParamParser ( ) ; } return this . defaultParamParser ; } | Returns the form parameter parser associated with the first context found that includes the URL or the default parser if it is not in a context |
20,570 | public Map < String , String > getParams ( HttpMessage msg , HtmlParameter . Type type ) { switch ( type ) { case form : return this . getFormParamParser ( msg . getRequestHeader ( ) . getURI ( ) . toString ( ) ) . getParams ( msg , type ) ; case url : return this . getUrlParamParser ( msg . getRequestHeader ( ) . getURI ( ) . toString ( ) ) . getParams ( msg , type ) ; default : throw new InvalidParameterException ( "Type not supported: " + type ) ; } } | Returns the specified parameters for the given message based on the parser associated with the first context found that includes the URL for the message or the default parser if it is not in a context |
20,571 | public Map < String , String > getUrlParams ( URI uri ) throws URIException { Map < String , String > map = new HashMap < > ( ) ; for ( NameValuePair parameter : getUrlParamParser ( uri . toString ( ) ) . parseParameters ( uri . getEscapedQuery ( ) ) ) { String value = parameter . getValue ( ) ; if ( value == null ) { value = "" ; } map . put ( parameter . getName ( ) , value ) ; } return map ; } | Returns the URL parameters for the given URL based on the parser associated with the first context found that includes the URL or the default parser if it is not in a context |
20,572 | public Map < String , String > getFormParams ( URI uri , String formData ) throws URIException { return this . getFormParamParser ( uri . toString ( ) ) . parse ( formData ) ; } | Returns the FORM parameters for the given URL based on the parser associated with the first context found that includes the URL or the default parser if it is not in a context |
20,573 | protected void readResponse ( HttpState state , HttpConnection conn ) throws IOException , HttpException { LOG . trace ( "enter HttpMethodBase.readResponse(HttpState, HttpConnection)" ) ; boolean isUpgrade = false ; while ( getStatusLine ( ) == null ) { readStatusLine ( state , conn ) ; processStatusLine ( state , conn ) ; readResponseHeaders ( state , conn ) ; processResponseHeaders ( state , conn ) ; int status = this . statusLine . getStatusCode ( ) ; if ( status == 101 ) { LOG . debug ( "Retrieved HTTP status code '101 Switching Protocols'. Keep connection open!" ) ; if ( conn instanceof ZapHttpConnection ) { isUpgrade = true ; conn . setHttpConnectionManager ( null ) ; } } else if ( ( status >= 100 ) && ( status < 200 ) ) { if ( LOG . isInfoEnabled ( ) ) { LOG . info ( "Discarding unexpected response: " + this . statusLine . toString ( ) ) ; } this . statusLine = null ; } } if ( conn instanceof ZapHttpConnection ) { ZapHttpConnection zapConn = ( ZapHttpConnection ) conn ; upgradedSocket = zapConn . getSocket ( ) ; inputStream = zapConn . getResponseInputStream ( ) ; } if ( ! isUpgrade ) { readResponseBody ( state , conn ) ; processResponseBody ( state , conn ) ; } } | Allow response code 101 that is Switching Protocols . |
20,574 | public void releaseConnection ( ) { Header header = getResponseHeader ( "content-type" ) ; if ( header != null ) { String contentTypeHeader = header . getValue ( ) ; if ( contentTypeHeader != null && contentTypeHeader . toLowerCase ( Locale . ROOT ) . contains ( "text/event-stream" ) ) { return ; } } super . releaseConnection ( ) ; } | Avoid releasing connection on event stream that is used in Server - Sent Events . |
20,575 | private static boolean isValidStartEndForLength ( int start , int end , int length ) { if ( start > length || end > length ) { return false ; } return true ; } | Tells whether or not the given start and end are valid for the given length that is both start and end are lower that the length . |
20,576 | private List < ClassNameWrapper > parseClassDir ( ClassLoader cl , File file , String packageName , FileFilter fileFilter ) { List < ClassNameWrapper > classNames = new ArrayList < > ( ) ; File [ ] listFile = file . listFiles ( fileFilter ) ; for ( int i = 0 ; i < listFile . length ; i ++ ) { File entry = listFile [ i ] ; if ( entry . isDirectory ( ) ) { classNames . addAll ( parseClassDir ( cl , entry , packageName , fileFilter ) ) ; continue ; } String fileName = entry . toString ( ) ; int pos = fileName . indexOf ( packageName ) ; if ( pos > 0 ) { String className = fileName . substring ( pos ) . replaceAll ( "\\.class$" , "" ) . replace ( File . separatorChar , '.' ) ; classNames . add ( new ClassNameWrapper ( cl , className ) ) ; } } return classNames ; } | passed with the dots replaced . |
20,577 | public void setUsers ( List < User > users ) { users . forEach ( u -> validateNonNull ( u ) ) ; this . users = new ArrayList < > ( users ) ; } | Sets a new list of users for this context . An internal copy of the provided list is stored . |
20,578 | public User getUserById ( int id ) { for ( User u : users ) if ( u . getId ( ) == id ) return u ; return null ; } | Gets the user with a given id . |
20,579 | public boolean removeUserById ( int id ) { Iterator < User > it = users . iterator ( ) ; while ( it . hasNext ( ) ) if ( it . next ( ) . getId ( ) == id ) { it . remove ( ) ; return true ; } return false ; } | Removes the user with a given id . |
20,580 | public void setDefaultTokens ( final List < HttpSessionToken > tokens ) { this . defaultTokens = tokens ; saveDefaultTokens ( ) ; this . defaultTokensEnabled = defaultTokens . stream ( ) . filter ( HttpSessionToken :: isEnabled ) . map ( HttpSessionToken :: getName ) . collect ( Collectors . toList ( ) ) ; } | Sets the default tokens . |
20,581 | public boolean addDefaultToken ( String name , boolean enabled ) { String normalisedName = getNormalisedSessionTokenName ( name ) ; if ( ! getDefaultToken ( normalisedName ) . isPresent ( ) ) { defaultTokens . add ( new HttpSessionToken ( normalisedName , enabled ) ) ; if ( enabled ) { defaultTokensEnabled . add ( normalisedName ) ; } saveDefaultTokens ( ) ; return true ; } return false ; } | Adds the default session token with the given name and enabled state . |
20,582 | private Optional < HttpSessionToken > getDefaultToken ( String name ) { return defaultTokens . stream ( ) . filter ( e -> name . equalsIgnoreCase ( e . getName ( ) ) ) . findFirst ( ) ; } | Gets the default session token with the given name . |
20,583 | public boolean setDefaultTokenEnabled ( String name , boolean enabled ) { Optional < HttpSessionToken > maybeToken = getDefaultToken ( getNormalisedSessionTokenName ( name ) ) ; if ( maybeToken . isPresent ( ) ) { HttpSessionToken token = maybeToken . get ( ) ; if ( token . isEnabled ( ) == enabled ) { return true ; } if ( token . isEnabled ( ) ) { defaultTokensEnabled . remove ( token . getName ( ) ) ; } else { defaultTokensEnabled . add ( token . getName ( ) ) ; } token . setEnabled ( enabled ) ; saveDefaultTokens ( ) ; return true ; } return false ; } | Sets whether or not the default session token with the given name is enabled . |
20,584 | public boolean removeDefaultToken ( String name ) { String normalisedName = getNormalisedSessionTokenName ( name ) ; Optional < HttpSessionToken > maybeToken = getDefaultToken ( normalisedName ) ; if ( maybeToken . isPresent ( ) ) { defaultTokens . remove ( maybeToken . get ( ) ) ; defaultTokensEnabled . remove ( normalisedName ) ; saveDefaultTokens ( ) ; return true ; } return false ; } | Removes the default session token with the given name . |
20,585 | private static String reverseString ( String in ) { StringBuilder out = new StringBuilder ( in ) . reverse ( ) ; return out . toString ( ) ; } | This method takes a string as input reverses it and returns the result |
20,586 | public String getLCS ( String strA , String strB ) { if ( "" . equals ( strA ) ) { return "" ; } StringBuilder sb = new StringBuilder ( ) ; algC ( sb , strA . length ( ) , strB . length ( ) , strA , strB ) ; return sb . toString ( ) ; } | Gets the Longest Common Subsequence of two strings using Dynamic programming techniques and minimal memory |
20,587 | public double getMatchRatio ( String strA , String strB ) { if ( strA == null && strB == null ) { return MAX_RATIO ; } else if ( strA == null || strB == null ) { return MIN_RATIO ; } if ( strA . isEmpty ( ) && strB . isEmpty ( ) ) { return MAX_RATIO ; } else if ( strA . isEmpty ( ) || strB . isEmpty ( ) ) { return MIN_RATIO ; } return ( double ) getLCS ( strA , strB ) . length ( ) / Math . max ( strA . length ( ) , strB . length ( ) ) ; } | Calculate the ratio of similarity between 2 strings using LCS |
20,588 | public static String currentDefaultFormattedTimeStamp ( ) { try { SimpleDateFormat sdf = new SimpleDateFormat ( DEFAULT_TIME_STAMP_FORMAT ) ; return sdf . format ( new Date ( ) ) ; } catch ( IllegalArgumentException e ) { SimpleDateFormat sdf = new SimpleDateFormat ( SAFE_TIME_STAMP_FORMAT ) ; return sdf . format ( new Date ( ) ) ; } } | Gets the current time stamp based on the DEFAULT format . The DEFAULT format is defined in Messages . properties . |
20,589 | private void doImport ( ) { if ( checkExistingCertificate ( ) ) { return ; } final JFileChooser fc = new JFileChooser ( System . getProperty ( "user.home" ) ) ; fc . setFileSelectionMode ( JFileChooser . FILES_ONLY ) ; fc . setMultiSelectionEnabled ( false ) ; fc . setSelectedFile ( new File ( CONFIGURATION_FILENAME ) ) ; fc . setFileFilter ( new FileFilter ( ) { public String getDescription ( ) { return Constant . messages . getString ( "dynssl.filter.file" ) ; } public boolean accept ( File f ) { String lcFileName = f . getName ( ) . toLowerCase ( Locale . ROOT ) ; return lcFileName . endsWith ( CONFIGURATION_FILENAME ) || lcFileName . endsWith ( "pem" ) || f . isDirectory ( ) ; } } ) ; final int result = fc . showOpenDialog ( this ) ; final File f = fc . getSelectedFile ( ) ; if ( result == JFileChooser . APPROVE_OPTION && f . exists ( ) ) { if ( logger . isInfoEnabled ( ) ) { logger . info ( "Loading Root CA certificate from " + f ) ; } KeyStore ks = null ; if ( f . getName ( ) . toLowerCase ( ) . endsWith ( "pem" ) ) { ks = convertPemFileToKeyStore ( f . toPath ( ) ) ; } else { try { final ZapXmlConfiguration conf = new ZapXmlConfiguration ( f ) ; final String rootcastr = conf . getString ( DynSSLParam . PARAM_ROOT_CA ) ; if ( rootcastr == null || rootcastr . isEmpty ( ) ) { JOptionPane . showMessageDialog ( this , Constant . messages . getString ( "dynssl.message.nocertinconf" ) , Constant . messages . getString ( "dynssl.message.nocertinconf.title" ) , JOptionPane . ERROR_MESSAGE ) ; return ; } ks = SslCertificateUtils . string2Keystore ( rootcastr ) ; } catch ( final Exception e ) { logger . error ( "Error importing Root CA cert from config file:" , e ) ; JOptionPane . showMessageDialog ( this , Constant . messages . getString ( "dynssl.message1.filecouldntloaded" ) , Constant . messages . getString ( "dynssl.message1.title" ) , JOptionPane . ERROR_MESSAGE ) ; return ; } } if ( ks != null ) { setRootca ( ks ) ; } } } | Import Root CA certificate from other ZAP configuration files . |
20,590 | private void doSave ( ) { if ( txt_PubCert . getDocument ( ) . getLength ( ) < MIN_CERT_LENGTH ) { logger . error ( "Illegal state! There seems to be no certificate available." ) ; bt_save . setEnabled ( false ) ; } final JFileChooser fc = new JFileChooser ( System . getProperty ( "user.home" ) ) ; fc . setFileSelectionMode ( JFileChooser . FILES_ONLY ) ; fc . setMultiSelectionEnabled ( false ) ; fc . setSelectedFile ( new File ( OWASP_ZAP_ROOT_CA_FILENAME ) ) ; if ( fc . showSaveDialog ( this ) == JFileChooser . APPROVE_OPTION ) { final File f = fc . getSelectedFile ( ) ; if ( logger . isInfoEnabled ( ) ) { logger . info ( "Saving Root CA certificate to " + f ) ; } try { writePubCertificateToFile ( f ) ; } catch ( final Exception e ) { logger . error ( "Error while writing certificate data to file " + f , e ) ; } } } | Saving Root CA certificate to disk . |
20,591 | private void doGenerate ( ) { if ( checkExistingCertificate ( ) ) { return ; } try { final KeyStore newrootca = SslCertificateUtils . createRootCA ( ) ; setRootca ( newrootca ) ; } catch ( final Exception e ) { logger . error ( "Error while generating Root CA certificate" , e ) ; } } | Generates a new Root CA certificate ... |
20,592 | private boolean checkExistingCertificate ( ) { boolean alreadyexists = txt_PubCert . getDocument ( ) . getLength ( ) > MIN_CERT_LENGTH ; if ( alreadyexists ) { final int result = JOptionPane . showConfirmDialog ( this , Constant . messages . getString ( "dynssl.message2.caalreadyexists" ) + "\n" + Constant . messages . getString ( "dynssl.message2.willreplace" ) + "\n\n" + Constant . messages . getString ( "dynssl.message2.wanttooverwrite" ) , Constant . messages . getString ( "dynssl.message2.title" ) , JOptionPane . YES_NO_OPTION ) ; alreadyexists = ! ( result == JOptionPane . YES_OPTION ) ; } return alreadyexists ; } | Check if certificate already exists . It will ask the user to overwrite . |
20,593 | public void shutdown ( boolean compact ) { try { if ( view != null ) { view . getRequestPanel ( ) . saveConfig ( model . getOptionsParam ( ) . getConfig ( ) ) ; view . getResponsePanel ( ) . saveConfig ( model . getOptionsParam ( ) . getConfig ( ) ) ; } getProxy ( null ) . stopServer ( ) ; super . shutdown ( compact ) ; } finally { saveConfigurations ( ) ; } } | Override inherited shutdown to add stopping proxy servers . |
20,594 | private void closeSessionAndCreateAndOpenUntitledDb ( ) throws Exception { getExtensionLoader ( ) . sessionAboutToChangeAllPlugin ( null ) ; model . closeSession ( ) ; log . info ( "Create and Open Untitled Db" ) ; model . createAndOpenUntitledDb ( ) ; } | Closes the old session and creates and opens an untitled database . |
20,595 | public void setTechSet ( TechSet techSet ) { Set < Tech > includedTech = techSet . getIncludeTech ( ) ; Iterator < Entry < Tech , DefaultMutableTreeNode > > iter = techToNodeMap . entrySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { Entry < Tech , DefaultMutableTreeNode > node = iter . next ( ) ; TreePath tp = this . getPath ( node . getValue ( ) ) ; Tech tech = node . getKey ( ) ; if ( ArrayUtils . contains ( Tech . builtInTopLevelTech , tech ) ) { techTree . check ( tp , containsAnyOfTopLevelTech ( includedTech , tech ) ) ; } else { techTree . check ( tp , techSet . includes ( tech ) ) ; } } } | Sets the technologies that should be selected if included and not if excluded . |
20,596 | private void scanVariant ( ) { for ( int i = 0 ; i < variant . getParamList ( ) . size ( ) && ! isStop ( ) ; i ++ ) { originalPair = variant . getParamList ( ) . get ( i ) ; if ( ! isToExclude ( originalPair ) ) { HttpMessage msg = getNewMsg ( ) ; try { scan ( msg , originalPair ) ; } catch ( Exception e ) { logger . error ( "Error occurred while scanning a message:" , e ) ; } } } } | Scan the current message using the current Variant |
20,597 | private boolean isToExclude ( NameValuePair param ) { List < ScannerParamFilter > excludedParameters = getParameterExclusionFilters ( param ) ; HttpMessage msg = getBaseMsg ( ) ; for ( ScannerParamFilter filter : excludedParameters ) { if ( filter . isToExclude ( msg , param ) ) { return true ; } } return false ; } | Inner method to check if the current parameter should be excluded |
20,598 | public void setConfig ( Configuration config ) { if ( config == null ) { throw new IllegalArgumentException ( "Parameter config must not be null." ) ; } this . config = config ; this . loadFrom ( config ) ; } | Sets the current configuration of the passive scanner . |
20,599 | private boolean isPluginConfiguration ( Configuration configuration ) { return ( configuration . containsKey ( ID_KEY ) && getPluginId ( ) == configuration . getInt ( ID_KEY ) ) || getClass ( ) . getCanonicalName ( ) . equals ( configuration . getString ( CLASSNAME_KEY , "" ) ) ; } | Tells whether or not the given configuration belongs to this passive scanner . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.