idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
20,800
private ZapTextField getTxtHeadline ( ) { if ( txtHeadline == null ) { txtHeadline = new ZapTextField ( ) ; txtHeadline . setBorder ( javax . swing . BorderFactory . createEtchedBorder ( javax . swing . border . EtchedBorder . RAISED ) ) ; txtHeadline . setEditable ( false ) ; txtHeadline . setEnabled ( false ) ; txtHeadline . setBackground ( java . awt . Color . white ) ; txtHeadline . setFont ( FontUtils . getFont ( Font . BOLD ) ) ; } return txtHeadline ; }
Gets text field that shows the name of the selected panel .
20,801
private DefaultTreeModel getTreeModel ( ) { if ( treeModel == null ) { treeModel = new DefaultTreeModel ( getRootNode ( ) ) ; treeModel . setRoot ( getRootNode ( ) ) ; } return treeModel ; }
This method initializes treeModel
20,802
public void removeParamPanel ( AbstractParamPanel panel ) { if ( currentShownPanel == panel ) { currentShownPanel = null ; nameLastSelectedPanel = null ; if ( isShowing ( ) ) { if ( tablePanel . isEmpty ( ) ) { getTxtHeadline ( ) . setText ( "" ) ; getHelpButton ( ) . setVisible ( false ) ; } else { getTreeParam ( ) . setSelectionPath ( new TreePath ( getFirstAvailableNode ( ) . getPath ( ) ) ) ; } } } DefaultMutableTreeNode node = this . getTreeNodeFromPanelName ( panel . getName ( ) , true ) ; if ( node != null ) { getTreeModel ( ) . removeNodeFromParent ( node ) ; } getPanelParam ( ) . remove ( panel ) ; tablePanel . remove ( panel . getName ( ) ) ; }
Removes the given panel .
20,803
public void initParam ( Object obj ) { paramObject = obj ; Enumeration < AbstractParamPanel > en = tablePanel . elements ( ) ; AbstractParamPanel panel = null ; while ( en . hasMoreElements ( ) ) { panel = en . nextElement ( ) ; panel . initParam ( obj ) ; } }
Initialises all panels with the given object .
20,804
public void expandParamPanelNode ( String panelName ) { DefaultMutableTreeNode node = getTreeNodeFromPanelName ( panelName ) ; if ( node != null ) { getTreeParam ( ) . expandPath ( new TreePath ( node . getPath ( ) ) ) ; } }
Expands the node of the param panel with the given name .
20,805
public boolean isParamPanelSelected ( String panelName ) { DefaultMutableTreeNode node = getTreeNodeFromPanelName ( panelName ) ; if ( node != null ) { return getTreeParam ( ) . isPathSelected ( new TreePath ( node . getPath ( ) ) ) ; } return false ; }
Tells whether or not the given param panel is selected .
20,806
public boolean isParamPanelOrChildSelected ( String panelName ) { DefaultMutableTreeNode node = getTreeNodeFromPanelName ( panelName ) ; if ( node != null ) { TreePath panelPath = new TreePath ( node . getPath ( ) ) ; if ( getTreeParam ( ) . isPathSelected ( panelPath ) ) { return true ; } TreePath selectedPath = getTreeParam ( ) . getSelectionPath ( ) ; return selectedPath != null && panelPath . equals ( selectedPath . getParentPath ( ) ) ; } return false ; }
Tells whether or not the given param panel or one of its child panels is selected .
20,807
private JScrollPane getJScrollPane1 ( ) { if ( jScrollPane1 == null ) { jScrollPane1 = new JScrollPane ( ) ; jScrollPane1 . setName ( "jScrollPane1" ) ; jScrollPane1 . setViewportView ( getJPanel ( ) ) ; jScrollPane1 . setHorizontalScrollBarPolicy ( javax . swing . JScrollPane . HORIZONTAL_SCROLLBAR_NEVER ) ; jScrollPane1 . setVerticalScrollBarPolicy ( javax . swing . JScrollPane . VERTICAL_SCROLLBAR_NEVER ) ; } return jScrollPane1 ; }
This method initializes jScrollPane1
20,808
private JButton getHelpButton ( ) { if ( btnHelp == null ) { btnHelp = new JButton ( ) ; btnHelp . setBorder ( null ) ; btnHelp . setIcon ( new ImageIcon ( AbstractParamContainerPanel . class . getResource ( "/resource/icon/16/201.png" ) ) ) ; btnHelp . addActionListener ( getShowHelpAction ( ) ) ; btnHelp . setToolTipText ( Constant . messages . getString ( "menu.help" ) ) ; } return btnHelp ; }
Gets the button that allows to show the help page of the panel .
20,809
private boolean isExcluded ( String uri ) { if ( excludeList == null || excludeList . isEmpty ( ) ) { return false ; } for ( String ex : excludeList ) { if ( uri . matches ( ex ) ) { return true ; } } return false ; }
Tells whether or not the given URI is excluded .
20,810
private boolean isDomainInScope ( String domain ) { for ( String scope : scopes ) { if ( domain . matches ( scope ) ) { return true ; } } return false ; }
Tells whether or not the given domain is one of the domains in scope .
20,811
private boolean isDomainAlwaysInScope ( String domain ) { for ( DomainAlwaysInScopeMatcher domainInScope : domainsAlwaysInScope ) { if ( domainInScope . matches ( domain ) ) { return true ; } } return false ; }
Tells whether or not the given domain is one of the domains always in scope .
20,812
public void setDomainsAlwaysInScope ( List < DomainAlwaysInScopeMatcher > domainsAlwaysInScope ) { if ( domainsAlwaysInScope == null || domainsAlwaysInScope . isEmpty ( ) ) { this . domainsAlwaysInScope = Collections . emptyList ( ) ; } else { this . domainsAlwaysInScope = domainsAlwaysInScope ; } }
Sets the domains that will be considered as always in scope .
20,813
private boolean paramAppend ( StringBuilder sb , String name , String value , ParameterParser parser ) { boolean isEdited = false ; if ( name != null ) { sb . append ( name ) ; isEdited = true ; } if ( value != null ) { sb . append ( parser . getDefaultKeyValueSeparator ( ) ) ; sb . append ( value ) ; isEdited = true ; } return isEdited ; }
Set the name value pair into the StringBuilder . If both name and value is null not to append whole parameter .
20,814
private LogPanel getLogPanel ( ) { if ( logPanel == null ) { logPanel = new LogPanel ( getView ( ) ) ; logPanel . setName ( Constant . messages . getString ( "history.panel.title" ) ) ; logPanel . setIcon ( new ImageIcon ( ExtensionHistory . class . getResource ( "/resource/icon/16/025.png" ) ) ) ; logPanel . setHideable ( false ) ; logPanel . setExtension ( this ) ; logPanel . setModel ( historyTableModel ) ; } return logPanel ; }
This method initializes logPanel
20,815
private static boolean isHistoryTypeToShow ( int historyType ) { return historyType == HistoryReference . TYPE_PROXIED || historyType == HistoryReference . TYPE_ZAP_USER || historyType == HistoryReference . TYPE_AUTHENTICATION || historyType == HistoryReference . TYPE_PROXY_CONNECT ; }
Tells whether or not the messages with the given history type should be shown in the History tab .
20,816
public ManualRequestEditorDialog getResendDialog ( ) { if ( resendDialog == null ) { resendDialog = new ManualHttpRequestEditorDialog ( true , "resend" , "ui.dialogs.manreq" ) ; resendDialog . setTitle ( Constant . messages . getString ( "manReq.dialog.title" ) ) ; } return resendDialog ; }
This method initializes resendDialog
20,817
public boolean isDefaultSessionToken ( String token ) { if ( getParam ( ) . getDefaultTokensEnabled ( ) . contains ( token . toLowerCase ( Locale . ENGLISH ) ) ) return true ; return false ; }
Checks if a particular token is part of the default session tokens set by the user using the options panel . The default session tokens are valid for all sites . The check is being performed in a lower - case manner as default session tokens are case - insensitive .
20,818
private boolean isRemovedDefaultSessionToken ( String site , String token ) { if ( removedDefaultTokens == null ) return false ; HashSet < String > removed = removedDefaultTokens . get ( site ) ; if ( removed == null || ! removed . contains ( token ) ) return false ; return true ; }
Checks if a particular default session token was removed by an user as a session token for a site .
20,819
private void markRemovedDefaultSessionToken ( String site , String token ) { if ( removedDefaultTokens == null ) removedDefaultTokens = new HashMap < > ( 1 ) ; HashSet < String > removedSet = removedDefaultTokens . get ( site ) ; if ( removedSet == null ) { removedSet = new HashSet < > ( 1 ) ; removedDefaultTokens . put ( site , removedSet ) ; } removedSet . add ( token ) ; }
Marks a default session token as removed for a particular site .
20,820
private void unmarkRemovedDefaultSessionToken ( String site , String token ) { if ( removedDefaultTokens == null ) return ; HashSet < String > removed = removedDefaultTokens . get ( site ) ; if ( removed == null ) return ; removed . remove ( token ) ; }
Unmarks a default session token as removed for a particular site .
20,821
public boolean isSessionToken ( String site , String token ) { if ( ! site . contains ( ":" ) ) { site = site + ( ":80" ) ; } HttpSessionTokensSet siteTokens = sessionTokens . get ( site ) ; if ( siteTokens == null ) return false ; return siteTokens . isSessionToken ( token ) ; }
Checks if a particular token is a session token name for a particular site .
20,822
public void addHttpSessionToken ( String site , String token ) { if ( ! site . contains ( ":" ) ) { site = site + ( ":80" ) ; } HttpSessionTokensSet siteTokens = sessionTokens . get ( site ) ; if ( siteTokens == null ) { siteTokens = new HttpSessionTokensSet ( ) ; sessionTokens . put ( site , siteTokens ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Added new session token for site '" + site + "': " + token ) ; } siteTokens . addToken ( token ) ; unmarkRemovedDefaultSessionToken ( site , token ) ; }
Adds a new session token for a particular site .
20,823
public List < HttpSession > getHttpSessionsForContext ( Context context ) { List < HttpSession > sessions = new LinkedList < > ( ) ; if ( this . sessions == null ) { return sessions ; } synchronized ( sessionLock ) { for ( Entry < String , HttpSessionsSite > e : this . sessions . entrySet ( ) ) { String siteName = e . getKey ( ) ; siteName = "http://" + siteName ; if ( context . isInContext ( siteName ) ) sessions . addAll ( e . getValue ( ) . getHttpSessions ( ) ) ; } } return sessions ; }
Builds and returns a list of http sessions that correspond to a given context .
20,824
public HttpSessionTokensSet getHttpSessionTokensSetForContext ( Context context ) { for ( Entry < String , HttpSessionTokensSet > e : this . sessionTokens . entrySet ( ) ) { String siteName = e . getKey ( ) ; siteName = "http://" + siteName ; if ( context . isInContext ( siteName ) ) return e . getValue ( ) ; } return null ; }
Gets the http session tokens set for the first site matching a given Context .
20,825
public List < String > getSites ( ) { List < String > sites = new ArrayList < String > ( ) ; if ( this . sessions == null ) { return sites ; } synchronized ( sessionLock ) { sites . addAll ( this . sessions . keySet ( ) ) ; } return sites ; }
Gets all of the sites with http sessions .
20,826
public void setLength ( int length ) { if ( length < 0 || body . length == length ) { return ; } int oldPos = pos ; pos = Math . min ( pos , length ) ; byte [ ] newBody = new byte [ length ] ; System . arraycopy ( body , 0 , newBody , 0 , pos ) ; body = newBody ; if ( oldPos > pos ) { cachedString = null ; } }
Sets the current length of the body . If the current content is longer the excessive data will be truncated .
20,827
static Pattern createIncludedFilesPattern ( ) { String messagesFilesRegex = LocaleUtils . createResourceFilesRegex ( Constant . MESSAGES_PREFIX , Constant . MESSAGES_EXTENSION ) ; String vulnerabilitiesFilesRegex = LocaleUtils . createResourceFilesRegex ( Constant . VULNERABILITIES_PREFIX , Constant . VULNERABILITIES_EXTENSION ) ; StringBuilder strBuilder = new StringBuilder ( messagesFilesRegex . length ( ) + vulnerabilitiesFilesRegex . length ( ) + 1 ) ; strBuilder . append ( messagesFilesRegex ) . append ( '|' ) . append ( vulnerabilitiesFilesRegex ) ; return Pattern . compile ( strBuilder . toString ( ) ) ; }
Relaxed visibility to allow unit test
20,828
public void setForcedUser ( int contextId , User user ) { if ( user != null ) this . contextForcedUsersMap . put ( contextId , user ) ; else this . contextForcedUsersMap . remove ( contextId ) ; this . updateForcedUserModeToggleButtonState ( ) ; }
Sets the forced user for a context .
20,829
public void setForcedUser ( int contextId , int userId ) throws IllegalStateException { User user = getUserManagementExtension ( ) . getContextUserAuthManager ( contextId ) . getUserById ( userId ) ; if ( user == null ) throw new IllegalStateException ( "No user matching the provided id was found." ) ; setForcedUser ( contextId , user ) ; }
Sets the forced user for a context based on the user id .
20,830
public byte [ ] getBytes ( ) { if ( ! changed ) { return buf ; } byte [ ] newBuf = new byte [ bufLen ] ; System . arraycopy ( buf , 0 , newBuf , 0 , bufLen ) ; buf = newBuf ; return buf ; }
Return the current byte array containing the bytes .
20,831
private void init ( ) { this . paused = false ; this . stopped = true ; this . tasksDoneCount = 0 ; this . tasksTotalCount = 0 ; this . initialized = false ; defaultFetchFilter = new DefaultFetchFilter ( ) ; this . addFetchFilter ( defaultFetchFilter ) ; for ( FetchFilter filter : extension . getCustomFetchFilters ( ) ) { this . addFetchFilter ( filter ) ; } this . addParseFilter ( new DefaultParseFilter ( spiderParam , extension . getMessages ( ) ) ) ; for ( ParseFilter filter : extension . getCustomParseFilters ( ) ) this . addParseFilter ( filter ) ; defaultFetchFilter . setScanContext ( this . scanContext ) ; defaultFetchFilter . setDomainsAlwaysInScope ( spiderParam . getDomainsAlwaysInScopeEnabled ( ) ) ; }
Initialize the spider .
20,832
public void setExcludeList ( List < String > excludeList ) { log . debug ( "New Exclude list: " + excludeList ) ; defaultFetchFilter . setExcludeRegexes ( excludeList ) ; }
Sets the exclude list which contains a List of strings defining the uris that should be excluded .
20,833
protected synchronized void submitTask ( SpiderTask task ) { if ( isStopped ( ) ) { log . debug ( "Submitting task skipped (" + task + ") as the Spider process is stopped." ) ; return ; } if ( isTerminated ( ) ) { log . debug ( "Submitting task skipped (" + task + ") as the Spider process is terminated." ) ; return ; } this . tasksTotalCount ++ ; try { this . threadPool . execute ( task ) ; } catch ( RejectedExecutionException e ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Submitted task was rejected (" + task + "), spider state: [stopped=" + isStopped ( ) + ", terminated=" + isTerminated ( ) + "]." ) ; } } }
Submit a new task to the spidering task pool .
20,834
public void start ( ) { log . info ( "Starting spider..." ) ; this . timeStarted = System . currentTimeMillis ( ) ; fetchFilterSeeds ( ) ; if ( seedList == null || seedList . isEmpty ( ) ) { log . warn ( "No seeds available for the Spider. Cancelling scan..." ) ; notifyListenersSpiderComplete ( false ) ; notifyListenersSpiderProgress ( 100 , 0 , 0 ) ; return ; } if ( scanUser != null ) log . info ( "Scan will be performed from the point of view of User: " + scanUser . getName ( ) ) ; this . controller . init ( ) ; this . stopped = false ; this . paused = false ; this . initialized = false ; this . threadPool = Executors . newFixedThreadPool ( spiderParam . getThreadCount ( ) , new SpiderThreadFactory ( "ZAP-SpiderThreadPool-" + id + "-thread-" ) ) ; httpSender = new HttpSender ( connectionParam , connectionParam . isHttpStateEnabled ( ) ? true : ! spiderParam . isAcceptCookies ( ) , HttpSender . SPIDER_INITIATOR ) ; httpSender . setFollowRedirect ( false ) ; for ( URI uri : seedList ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Adding seed for spider: " + uri ) ; } controller . addSeed ( uri , HttpRequestHeader . GET ) ; } initialized = true ; }
Starts the Spider crawling .
20,835
private void fetchFilterSeeds ( ) { if ( seedList == null || seedList . isEmpty ( ) ) { return ; } for ( Iterator < URI > it = seedList . iterator ( ) ; it . hasNext ( ) ; ) { URI seed = it . next ( ) ; for ( FetchFilter filter : controller . getFetchFilters ( ) ) { FetchStatus filterReason = filter . checkFilter ( seed ) ; if ( filterReason != FetchStatus . VALID ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Seed: " + seed + " was filtered with reason: " + filterReason ) ; } it . remove ( ) ; break ; } } } }
Filters the seed list using the current fetch filters preventing any non - valid seed from being accessed .
20,836
public void stop ( ) { if ( stopped ) { return ; } this . stopped = true ; log . info ( "Stopping spidering process by request." ) ; if ( this . paused ) { this . resume ( ) ; } this . threadPool . shutdown ( ) ; try { if ( ! this . threadPool . awaitTermination ( 2 , TimeUnit . SECONDS ) ) { log . warn ( "Failed to await for all spider threads to stop in the given time (2s)..." ) ; for ( Runnable task : this . threadPool . shutdownNow ( ) ) { ( ( SpiderTask ) task ) . cleanup ( ) ; } } } catch ( InterruptedException ignore ) { log . warn ( "Interrupted while awaiting for all spider threads to stop..." ) ; } if ( httpSender != null ) { this . getHttpSender ( ) . shutdown ( ) ; httpSender = null ; } controller . reset ( ) ; this . threadPool = null ; notifyListenersSpiderComplete ( false ) ; }
Stops the Spider crawling . Must not be called from any of the threads in the thread pool .
20,837
private void complete ( ) { if ( stopped ) { return ; } log . info ( "Spidering process is complete. Shutting down..." ) ; this . stopped = true ; if ( httpSender != null ) { this . getHttpSender ( ) . shutdown ( ) ; httpSender = null ; } controller . reset ( ) ; new Thread ( new Runnable ( ) { public void run ( ) { if ( threadPool != null ) { threadPool . shutdown ( ) ; } notifyListenersSpiderComplete ( true ) ; controller . reset ( ) ; threadPool = null ; } } , "ZAP-SpiderShutdownThread-" + id ) . start ( ) ; }
The Spidering process is complete .
20,838
protected void checkPauseAndWait ( ) { pauseLock . lock ( ) ; try { while ( paused && ! stopped ) { pausedCondition . await ( ) ; } } catch ( InterruptedException e ) { } finally { pauseLock . unlock ( ) ; } }
This method is run by Threads in the ThreadPool and checks if the scan is paused and if it is waits until it s unpaused .
20,839
protected synchronized void postTaskExecution ( ) { if ( stopped ) { return ; } tasksDoneCount ++ ; int percentageComplete = tasksDoneCount * 100 / tasksTotalCount ; this . notifyListenersSpiderProgress ( percentageComplete , tasksDoneCount , tasksTotalCount - tasksDoneCount ) ; if ( tasksDoneCount == tasksTotalCount && initialized ) { this . complete ( ) ; } }
This method is run by each thread in the Thread Pool after the task execution . Particularly it notifies the listeners of the progress and checks if the scan is complete . Called from the SpiderTask .
20,840
public boolean isStopped ( ) { if ( ! stopped && this . spiderParam . getMaxDuration ( ) > 0 ) { if ( TimeUnit . MILLISECONDS . toMinutes ( System . currentTimeMillis ( ) - this . timeStarted ) > this . spiderParam . getMaxDuration ( ) ) { log . info ( "Spidering process has exceeded maxDuration of " + this . spiderParam . getMaxDuration ( ) + " minute(s)" ) ; this . complete ( ) ; } } return stopped ; }
Checks if is stopped i . e . a shutdown was issued or it is not running .
20,841
protected synchronized void notifyListenersSpiderProgress ( int percentageComplete , int numberCrawled , int numberToCrawl ) { for ( SpiderListener l : listeners ) { l . spiderProgress ( percentageComplete , numberCrawled , numberToCrawl ) ; } }
Notifies all the listeners regarding the spider progress .
20,842
protected synchronized void notifyListenersFoundURI ( String uri , String method , FetchStatus status ) { for ( SpiderListener l : listeners ) { l . foundURI ( uri , method , status ) ; } }
Notifies the listeners regarding a found uri .
20,843
public void addContextDataFactory ( ContextDataFactory contextDataFactory ) { if ( contextDataFactory == null ) { throw new IllegalArgumentException ( "Parameter contextDataFactory must not be null." ) ; } this . contextDataFactories . add ( contextDataFactory ) ; if ( postInitialisation ) { for ( Context context : getSession ( ) . getContexts ( ) ) { contextDataFactory . loadContextData ( getSession ( ) , context ) ; } } }
Adds the given context data factory to the model .
20,844
public void importContext ( Context ctx , Configuration config ) throws ConfigurationException { validateContextNotNull ( ctx ) ; validateConfigNotNull ( config ) ; for ( ContextDataFactory cdf : this . contextDataFactories ) { cdf . importContextData ( ctx , config ) ; } }
Import a context from the given configuration
20,845
public void exportContext ( Context ctx , Configuration config ) { validateContextNotNull ( ctx ) ; validateConfigNotNull ( config ) ; for ( ContextDataFactory cdf : this . contextDataFactories ) { cdf . exportContextData ( ctx , config ) ; } }
Export a context into the given configuration
20,846
protected T getRowObject ( int rowIndex ) { int pageIndex = rowIndex - dataOffset ; if ( pageIndex >= 0 && pageIndex < data . size ( ) ) { return data . get ( pageIndex ) ; } return null ; }
Gets the object at the given row .
20,847
private void notifyPostResourceFound ( HttpMessage message , int depth , String url , String requestBody ) { log . debug ( "Submiting form with POST method and message body with form parameters (normal encoding): " + requestBody ) ; notifyListenersPostResourceFound ( message , depth + 1 , url , requestBody ) ; }
Notifies listeners that a new POST resource was found .
20,848
private PopupEncoder2Menu getPopupMenuEncode ( ) { if ( popupEncodeMenu == null ) { popupEncodeMenu = new PopupEncoder2Menu ( ) ; popupEncodeMenu . setText ( Constant . messages . getString ( "enc2.popup" ) ) ; popupEncodeMenu . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { showEncodeDecodeDialog ( popupEncodeMenu . getLastInvoker ( ) ) ; } } ) ; } return popupEncodeMenu ; }
This method initializes popupEncodeMenu
20,849
protected JPanel getWorkPanel ( ) { if ( mainPanel == null ) { mainPanel = new JPanel ( new BorderLayout ( ) ) ; tabbedPane = new JTabbedPane ( ) ; tabbedPane . addTab ( Constant . messages . getString ( "spider.panel.tab.urls" ) , getUrlsTableScrollPane ( ) ) ; tabbedPane . addTab ( Constant . messages . getString ( "spider.panel.tab.addednodes" ) , getAddedNodesTableScrollPane ( ) ) ; tabbedPane . addTab ( Constant . messages . getString ( "spider.panel.tab.messages" ) , getMessagesTableScrollPanel ( ) ) ; tabbedPane . setSelectedIndex ( 0 ) ; mainPanel . add ( tabbedPane ) ; } return mainPanel ; }
This method initializes the working Panel .
20,850
private JXTable getUrlsTable ( ) { if ( urlsTable == null ) { urlsTable = new ZapTable ( EMPTY_URLS_TABLE_MODEL ) ; urlsTable . setColumnSelectionAllowed ( false ) ; urlsTable . setCellSelectionEnabled ( false ) ; urlsTable . setRowSelectionAllowed ( true ) ; urlsTable . setAutoCreateRowSorter ( true ) ; urlsTable . setAutoCreateColumnsFromModel ( false ) ; urlsTable . getColumnExt ( 0 ) . setCellRenderer ( new DefaultTableRenderer ( new MappedValue ( StringValues . EMPTY , IconValues . NONE ) , JLabel . CENTER ) ) ; urlsTable . getColumnExt ( 0 ) . setHighlighters ( new ProcessedCellItemIconHighlighter ( 0 ) ) ; urlsTable . getColumnModel ( ) . getColumn ( 0 ) . setMinWidth ( 80 ) ; urlsTable . getColumnModel ( ) . getColumn ( 0 ) . setPreferredWidth ( 90 ) ; urlsTable . getColumnModel ( ) . getColumn ( 1 ) . setMinWidth ( 60 ) ; urlsTable . getColumnModel ( ) . getColumn ( 1 ) . setPreferredWidth ( 70 ) ; urlsTable . getColumnModel ( ) . getColumn ( 2 ) . setMinWidth ( 300 ) ; urlsTable . getColumnModel ( ) . getColumn ( 3 ) . setMinWidth ( 50 ) ; urlsTable . getColumnModel ( ) . getColumn ( 3 ) . setPreferredWidth ( 250 ) ; urlsTable . setName ( PANEL_NAME ) ; urlsTable . setDoubleBuffered ( true ) ; urlsTable . setSelectionMode ( ListSelectionModel . MULTIPLE_INTERVAL_SELECTION ) ; urlsTable . setComponentPopupMenu ( new JPopupMenu ( ) { private static final long serialVersionUID = 6608291059686282641L ; public void show ( Component invoker , int x , int y ) { View . getSingleton ( ) . getPopupMenu ( ) . show ( invoker , x , y ) ; } } ) ; } return urlsTable ; }
Gets the scan results table .
20,851
private JLabel getFoundCountNameLabel ( ) { if ( foundCountNameLabel == null ) { foundCountNameLabel = new JLabel ( ) ; foundCountNameLabel . setText ( Constant . messages . getString ( "spider.toolbar.found.label" ) ) ; } return foundCountNameLabel ; }
Gets the label storing the name of the count of found URIs .
20,852
private JLabel getFoundCountValueLabel ( ) { if ( foundCountValueLabel == null ) { foundCountValueLabel = new JLabel ( ) ; foundCountValueLabel . setText ( ZERO_REQUESTS_LABEL_TEXT ) ; } return foundCountValueLabel ; }
Gets the label storing the value for count of found URIs .
20,853
private JLabel getAddedCountNameLabel ( ) { if ( addedCountNameLabel == null ) { addedCountNameLabel = new JLabel ( ) ; addedCountNameLabel . setText ( Constant . messages . getString ( "spider.toolbar.added.label" ) ) ; } return addedCountNameLabel ; }
Gets the label storing the name of the count of added URIs .
20,854
private JLabel getAddedCountValueLabel ( ) { if ( addedCountValueLabel == null ) { addedCountValueLabel = new JLabel ( ) ; addedCountValueLabel . setText ( ZERO_REQUESTS_LABEL_TEXT ) ; } return addedCountValueLabel ; }
Gets the label storing the value for count of added URIs .
20,855
protected void updateFoundCount ( ) { SpiderScan sc = this . getSelectedScanner ( ) ; if ( sc != null ) { this . getFoundCountValueLabel ( ) . setText ( Integer . toString ( sc . getNumberOfURIsFound ( ) ) ) ; } else { this . getFoundCountValueLabel ( ) . setText ( ZERO_REQUESTS_LABEL_TEXT ) ; } }
Update the count of found URIs .
20,856
protected void updateAddedCount ( ) { SpiderScan sc = this . getSelectedScanner ( ) ; if ( sc != null ) { this . getAddedCountValueLabel ( ) . setText ( Integer . toString ( sc . getNumberOfNodesAdded ( ) ) ) ; } else { this . getAddedCountValueLabel ( ) . setText ( ZERO_REQUESTS_LABEL_TEXT ) ; } }
Update the count of added nodes .
20,857
private void initialize ( ) { this . setLayout ( new CardLayout ( ) ) ; this . setName ( Constant . messages . getString ( "variant.options.title" ) ) ; this . add ( getPanelScanner ( ) , getPanelScanner ( ) . getName ( ) ) ; }
This method initializes the Panel
20,858
public void saveParam ( ScannerParam param ) { int targets = 0 ; if ( this . getChkInjectableQueryString ( ) . isSelected ( ) ) { targets |= ScannerParam . TARGET_QUERYSTRING ; } param . setAddQueryParam ( getChkAddQueryParam ( ) . isSelected ( ) ) ; if ( this . getChkInjectableUrlPath ( ) . isSelected ( ) ) { targets |= ScannerParam . TARGET_URLPATH ; } if ( this . getChkInjectablePostData ( ) . isSelected ( ) ) { targets |= ScannerParam . TARGET_POSTDATA ; } if ( this . getChkInjectableHeaders ( ) . isSelected ( ) ) { targets |= ScannerParam . TARGET_HTTPHEADERS ; } param . setScanHeadersAllRequests ( getChkInjectableHeadersAllRequests ( ) . isSelected ( ) ) ; if ( this . getChkInjectableCookie ( ) . isSelected ( ) ) { targets |= ScannerParam . TARGET_COOKIE ; } param . setTargetParamsInjectable ( targets ) ; int enabledRpc = 0 ; if ( this . getChkRPCMultipart ( ) . isSelected ( ) ) { enabledRpc |= ScannerParam . RPC_MULTIPART ; } if ( this . getChkRPCXML ( ) . isSelected ( ) ) { enabledRpc |= ScannerParam . RPC_XML ; } if ( this . getChkRPCJSON ( ) . isSelected ( ) ) { enabledRpc |= ScannerParam . RPC_JSON ; } if ( this . getChkRPCGWT ( ) . isSelected ( ) ) { enabledRpc |= ScannerParam . RPC_GWT ; } if ( this . getChkRPCoData ( ) . isSelected ( ) ) { enabledRpc |= ScannerParam . RPC_ODATA ; } if ( this . getChkRPCDWR ( ) . isSelected ( ) ) { enabledRpc |= ScannerParam . RPC_DWR ; } if ( this . getChkRPCCustom ( ) . isSelected ( ) ) { enabledRpc |= ScannerParam . RPC_CUSTOM ; } param . setTargetParamsEnabledRPC ( enabledRpc ) ; param . setExcludedParamList ( getExcludedParameterModel ( ) . getElements ( ) ) ; }
Saves the options shown in the panel to the given options object .
20,859
public void setAllInjectableAndRPC ( boolean enabled ) { this . getChkInjectableQueryString ( ) . setEnabled ( enabled ) ; this . getChkAddQueryParam ( ) . setEnabled ( enabled && getChkInjectableQueryString ( ) . isSelected ( ) ) ; this . getChkInjectableUrlPath ( ) . setEnabled ( enabled ) ; this . getChkInjectablePostData ( ) . setEnabled ( enabled ) ; this . getChkInjectableHeaders ( ) . setEnabled ( enabled ) ; this . getChkInjectableHeadersAllRequests ( ) . setEnabled ( enabled && getChkInjectableHeaders ( ) . isSelected ( ) ) ; this . getChkInjectableCookie ( ) . setEnabled ( enabled ) ; this . getChkRPCMultipart ( ) . setEnabled ( enabled ) ; this . getChkRPCXML ( ) . setEnabled ( enabled ) ; this . getChkRPCJSON ( ) . setEnabled ( enabled ) ; this . getChkRPCGWT ( ) . setEnabled ( enabled ) ; this . getChkRPCoData ( ) . setEnabled ( enabled ) ; this . getChkRPCDWR ( ) . setEnabled ( enabled ) ; this . getChkRPCCustom ( ) . setEnabled ( enabled && isExtensionScriptEnabled ( ) ) ; if ( ! reasonVariantsDisabled . isEmpty ( ) ) { labelReasonVariantsDisabled . setVisible ( ! enabled ) ; } }
Set all checkbox to a specific value
20,860
public void setReasonVariantsDisabled ( String reason ) { reasonVariantsDisabled = Objects . requireNonNull ( reason ) ; labelReasonVariantsDisabled . setText ( reasonVariantsDisabled ) ; if ( reasonVariantsDisabled . isEmpty ( ) && labelReasonVariantsDisabled . isVisible ( ) ) { labelReasonVariantsDisabled . setVisible ( false ) ; } }
Sets the reason to show when the the variants are disabled .
20,861
public ApiResponse handleApiView ( String name , JSONObject params ) throws ApiException { throw new ApiException ( ApiException . Type . BAD_VIEW , name ) ; }
Override if implementing one or more views
20,862
public ApiResponse handleApiAction ( String name , JSONObject params ) throws ApiException { throw new ApiException ( ApiException . Type . BAD_ACTION , name ) ; }
Override if implementing one or more actions
20,863
public HttpMessage handleApiOther ( HttpMessage msg , String name , JSONObject params ) throws ApiException { throw new ApiException ( ApiException . Type . BAD_OTHER , name ) ; }
Override if implementing one or more other operations - these are operations that _dont_ return structured data
20,864
public void handleApiPersistentConnection ( HttpMessage msg , HttpInputStream httpIn , HttpOutputStream httpOut , String name , JSONObject params ) throws ApiException { throw new ApiException ( ApiException . Type . BAD_PCONN , name ) ; }
Override if implementing one or more persistent connection operations . These are operations that maintain long running connections potentially staying alive as long as the client holds them open .
20,865
public String handleCallBack ( HttpMessage msg ) throws ApiException { throw new ApiException ( ApiException . Type . URL_NOT_FOUND , msg . getRequestHeader ( ) . getURI ( ) . toString ( ) ) ; }
Override if handling callbacks
20,866
protected void notifyListenersResourceFound ( HttpMessage message , int depth , String uri ) { for ( SpiderParserListener l : listeners ) { l . resourceURIFound ( message , depth , uri ) ; } }
Notify the listeners that a resource was found .
20,867
protected void processURL ( HttpMessage message , int depth , String localURL , String baseURL ) { String fullURL = URLCanonicalizer . getCanonicalURL ( localURL , baseURL ) ; if ( fullURL == null ) { return ; } log . debug ( "Canonical URL constructed using '" + localURL + "': " + fullURL ) ; notifyListenersResourceFound ( message , depth + 1 , fullURL ) ; }
Builds an url and notifies the listeners .
20,868
public Component getTreeCellRendererComponent ( JTree tree , Object value , boolean sel , boolean expanded , boolean leaf , int row , boolean hasFocus ) { super . getTreeCellRendererComponent ( tree , value , sel , expanded , leaf , row , hasFocus ) ; if ( value instanceof AlertNode ) { AlertNode alertNode = ( AlertNode ) value ; if ( alertNode . isRoot ( ) ) { if ( expanded ) { this . setIcon ( FOLDER_OPEN_ICON ) ; } else { this . setIcon ( FOLDER_CLOSED_ICON ) ; } } else if ( alertNode . getParent ( ) . isRoot ( ) ) { Alert alert = alertNode . getUserObject ( ) ; this . setIcon ( alert . getIcon ( ) ) ; } else { this . setIcon ( LEAF_ICON ) ; } } return this ; }
Sets the relevant tree icons .
20,869
public static HttpSession getMatchingHttpSession ( final Collection < HttpSession > sessions , List < HttpCookie > cookies , final HttpSessionTokensSet siteTokens ) { if ( sessions . isEmpty ( ) ) { return null ; } List < HttpSession > matchingSessions = new LinkedList < > ( sessions ) ; for ( String token : siteTokens . getTokensSet ( ) ) { HttpCookie matchingCookie = null ; for ( HttpCookie cookie : cookies ) { if ( cookie . getName ( ) . equals ( token ) ) { matchingCookie = cookie ; break ; } } Iterator < HttpSession > it = matchingSessions . iterator ( ) ; while ( it . hasNext ( ) ) { if ( ! it . next ( ) . matchesToken ( token , matchingCookie ) ) { it . remove ( ) ; } } } if ( matchingSessions . size ( ) >= 1 ) { if ( matchingSessions . size ( ) > 1 ) { log . warn ( "Multiple sessions matching the cookies from response. Using first one." ) ; } return matchingSessions . get ( 0 ) ; } return null ; }
Gets the matching http session if any for a particular message containing a list of cookies from a set of sessions .
20,870
protected String getEscapedValue ( HttpMessage msg , String value ) { return ( value != null ) ? AbstractPlugin . getURLEncode ( value ) : "" ; }
Encode the parameter for a correct URL introduction
20,871
private void writeOutArgs ( List < String > elements , Writer out , boolean hasParams ) throws IOException { if ( elements != null && elements . size ( ) > 0 ) { ArrayList < String > args = new ArrayList < String > ( ) ; for ( String param : elements ) { if ( param . equalsIgnoreCase ( "boolean" ) ) { args . add ( "boolean bool" ) ; } else if ( param . equalsIgnoreCase ( "integer" ) ) { args . add ( "i int" ) ; } else if ( param . equalsIgnoreCase ( "string" ) ) { args . add ( "str string" ) ; } else if ( param . equalsIgnoreCase ( "type" ) ) { args . add ( "t string" ) ; } else { args . add ( param . toLowerCase ( ) + " string" ) ; } } out . write ( StringUtils . join ( args , ", " ) ) ; } }
Writes the function arguments
20,872
private void writeOutRequestParams ( List < String > elements , Writer out ) throws IOException { if ( elements != null && elements . size ( ) > 0 ) { for ( String param : elements ) { out . write ( "\n\t\t\"" + param + "\": " ) ; if ( param . equalsIgnoreCase ( "boolean" ) ) { addImports = true ; out . write ( "strconv.FormatBool(boolean)" ) ; } else if ( param . equalsIgnoreCase ( "integer" ) ) { addImports = true ; out . write ( "strconv.Itoa(i)" ) ; } else if ( param . equalsIgnoreCase ( "string" ) ) { out . write ( "str" ) ; } else if ( param . equalsIgnoreCase ( "type" ) ) { out . write ( "t" ) ; } else { out . write ( param . toLowerCase ( ) ) ; } out . write ( "," ) ; } } }
Writes the request parameters
20,873
private static void addImports ( Path file , boolean addImports ) throws IOException { Charset charset = StandardCharsets . UTF_8 ; String content = new String ( Files . readAllBytes ( file ) , charset ) ; if ( addImports ) { content = content . replaceAll ( "_imports_" , "import \"strconv\"\n\n" ) ; } else { content = content . replaceAll ( "_imports_" , "" ) ; } Files . write ( file , content . getBytes ( charset ) ) ; }
or removes it in case there isn t any packages to import
20,874
public List < ImageIcon > getCustomIcons ( ) { List < ImageIcon > iconList = new ArrayList < ImageIcon > ( ) ; if ( justSpidered ) { iconList . add ( new ImageIcon ( Constant . class . getResource ( "/resource/icon/10/spider.png" ) ) ) ; } synchronized ( this . icons ) { if ( ! this . icons . isEmpty ( ) ) { for ( Iterator < String > it = icons . iterator ( ) ; it . hasNext ( ) ; ) { String icon = it . next ( ) ; URL url = Constant . class . getResource ( icon ) ; if ( url == null ) { url = ExtensionFactory . getAddOnLoader ( ) . getResource ( icon ) ; if ( url == null ) { log . warn ( "Failed to find icon: " + icon ) ; it . remove ( ) ; } } if ( url != null ) { iconList . add ( new ImageIcon ( url ) ) ; } } } } return iconList ; }
Gets any custom icons that have been set for this node
20,875
public void setHistoryReference ( HistoryReference historyReference ) { if ( getHistoryReference ( ) != null ) { if ( this . justSpidered && ( historyReference . getHistoryType ( ) == HistoryReference . TYPE_PROXIED || historyReference . getHistoryType ( ) == HistoryReference . TYPE_ZAP_USER ) ) { this . justSpidered = false ; this . nodeChanged ( ) ; } if ( ! this . icons . isEmpty ( ) && ( historyReference . getHistoryType ( ) == HistoryReference . TYPE_PROXIED || historyReference . getHistoryType ( ) == HistoryReference . TYPE_ZAP_USER ) ) { synchronized ( this . icons ) { for ( int i = 0 ; i < this . clearIfManual . size ( ) ; ++ i ) { if ( this . clearIfManual . get ( i ) && this . icons . size ( ) > i ) { this . icons . remove ( i ) ; this . clearIfManual . remove ( i ) ; } } } this . nodeChanged ( ) ; } if ( HistoryReference . TYPE_SCANNER == historyReference . getHistoryType ( ) ) { getPastHistoryReference ( ) . add ( historyReference ) ; return ; } if ( ! getPastHistoryReference ( ) . contains ( getHistoryReference ( ) ) ) { getPastHistoryReference ( ) . add ( getHistoryReference ( ) ) ; } } this . historyReference = historyReference ; this . historyReference . setSiteNode ( this ) ; }
Set current node reference . If there is any existing reference delete if spider record . Otherwise put into past history list .
20,876
public void deleteAllAlerts ( ) { for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) { ( ( SiteNode ) getChildAt ( i ) ) . deleteAllAlerts ( ) ; } if ( ! alerts . isEmpty ( ) ) { alerts . clear ( ) ; highestAlert = null ; calculateHighestAlert = false ; if ( this . siteMap != null ) { siteMap . applyFilter ( this ) ; } nodeChanged ( ) ; } }
Deletes all alerts of this node and all child nodes recursively .
20,877
public HttpMessage getHttpMessage ( ) throws HttpMalformedHeaderException , DatabaseException { if ( httpMessage != null ) { return httpMessage ; } RecordHistory history = staticTableHistory . read ( historyId ) ; if ( history == null ) { throw new HttpMalformedHeaderException ( "No history reference for id " + historyId + " type=" + historyType ) ; } history . getHttpMessage ( ) . setHistoryRef ( this ) ; return history . getHttpMessage ( ) ; }
Gets the corresponding http message from the database . Try to minimise calls to this method as much as possible . But also dont cache the HttpMessage either as this can significantly increase ZAP s memory usage .
20,878
public void setTags ( List < String > tags ) { if ( tags == null ) { throw new IllegalArgumentException ( "Parameter tags must not be null." ) ; } for ( String tag : tags ) { if ( ! this . tags . contains ( tag ) ) { insertTagDb ( tag ) ; } } for ( String tag : this . tags ) { if ( ! tags . contains ( tag ) ) { deleteTagDb ( tag ) ; } } this . tags = new ArrayList < > ( tags ) ; notifyEvent ( HistoryReferenceEventPublisher . EVENT_TAGS_SET ) ; }
Sets the tags for the HTTP message .
20,879
public static List < String > getTags ( int historyId ) throws DatabaseException { if ( staticTableTag == null ) { return new ArrayList < > ( ) ; } List < String > tags = new ArrayList < > ( ) ; List < RecordTag > rtags = staticTableTag . getTagsForHistoryID ( historyId ) ; for ( RecordTag rtag : rtags ) { tags . add ( rtag . getTag ( ) ) ; } return tags ; }
Gets the tags of the message with the given history ID .
20,880
protected static char [ ] encode ( String original , BitSet allowed , String charset ) throws URIException { if ( original == null ) { throw new IllegalArgumentException ( "Original string may not be null" ) ; } if ( allowed == null ) { throw new IllegalArgumentException ( "Allowed bitset may not be null" ) ; } byte [ ] rawdata = URLCodec . encodeUrl ( allowed , EncodingUtil . getBytes ( original , charset ) ) ; return EncodingUtil . getAsciiString ( rawdata ) . toCharArray ( ) ; }
Encodes URI string .
20,881
protected boolean prevalidate ( String component , BitSet disallowed ) { if ( component == null ) { return false ; } char [ ] target = component . toCharArray ( ) ; for ( int i = 0 ; i < target . length ; i ++ ) { if ( disallowed . get ( target [ i ] ) ) { return false ; } } return true ; }
Pre - validate the unescaped URI string within a specific component .
20,882
protected int indexFirstOf ( char [ ] s , char delim , int offset ) { if ( s == null || s . length == 0 ) { return - 1 ; } if ( offset < 0 ) { offset = 0 ; } else if ( offset > s . length ) { return - 1 ; } for ( int i = offset ; i < s . length ; i ++ ) { if ( s [ i ] == delim ) { return i ; } } return - 1 ; }
Get the earlier index that to be searched for the first occurrance in one of any of the given array .
20,883
protected void parseAuthority ( String original , boolean escaped ) throws URIException { _is_reg_name = _is_server = _is_hostname = _is_IPv4address = _is_IPv6reference = false ; String charset = getProtocolCharset ( ) ; boolean hasPort = true ; int from = 0 ; int next = original . indexOf ( '@' ) ; if ( next != - 1 ) { _userinfo = ( escaped ) ? original . substring ( 0 , next ) . toCharArray ( ) : encode ( original . substring ( 0 , next ) , allowed_userinfo , charset ) ; from = next + 1 ; } next = original . indexOf ( '[' , from ) ; if ( next >= from ) { next = original . indexOf ( ']' , from ) ; if ( next == - 1 ) { throw new URIException ( URIException . PARSING , "IPv6reference" ) ; } else { next ++ ; } _host = ( escaped ) ? original . substring ( from , next ) . toCharArray ( ) : encode ( original . substring ( from , next ) , allowed_IPv6reference , charset ) ; _is_IPv6reference = true ; } else { next = original . indexOf ( ':' , from ) ; if ( next == - 1 ) { next = original . length ( ) ; hasPort = false ; } _host = original . substring ( from , next ) . toCharArray ( ) ; if ( validate ( _host , IPv4address ) ) { _is_IPv4address = true ; } else if ( validate ( _host , hostname ) ) { _is_hostname = true ; } else { _is_reg_name = true ; } } if ( _is_reg_name ) { _is_server = _is_hostname = _is_IPv4address = _is_IPv6reference = false ; if ( escaped ) { _authority = original . toCharArray ( ) ; if ( ! validate ( _authority , reg_name ) ) { throw new URIException ( "Invalid authority" ) ; } } else { _authority = encode ( original , allowed_reg_name , charset ) ; } } else { if ( original . length ( ) - 1 > next && hasPort && original . charAt ( next ) == ':' ) { from = next + 1 ; try { _port = Integer . parseInt ( original . substring ( from ) ) ; } catch ( NumberFormatException error ) { throw new URIException ( URIException . PARSING , "invalid port number" ) ; } } StringBuffer buf = new StringBuffer ( ) ; if ( _userinfo != null ) { buf . append ( _userinfo ) ; buf . append ( '@' ) ; } if ( _host != null ) { buf . append ( _host ) ; if ( _port != - 1 ) { buf . append ( ':' ) ; buf . append ( _port ) ; } } _authority = buf . toString ( ) . toCharArray ( ) ; _is_server = true ; } }
Parse the authority component .
20,884
protected void setURI ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( _scheme != null ) { buf . append ( _scheme ) ; buf . append ( ':' ) ; } if ( _is_net_path ) { buf . append ( "//" ) ; if ( _authority != null ) { buf . append ( _authority ) ; } } if ( _opaque != null && _is_opaque_part ) { buf . append ( _opaque ) ; } else if ( _path != null ) { if ( _path . length != 0 ) { buf . append ( _path ) ; } } if ( _query != null ) { buf . append ( '?' ) ; buf . append ( _query ) ; } _uri = buf . toString ( ) . toCharArray ( ) ; hash = 0 ; }
Once it s parsed successfully set this URI .
20,885
public void setRawPath ( char [ ] escapedPath ) throws URIException { if ( escapedPath == null || escapedPath . length == 0 ) { _path = _opaque = escapedPath ; setURI ( ) ; return ; } escapedPath = removeFragmentIdentifier ( escapedPath ) ; if ( _is_net_path || _is_abs_path ) { if ( escapedPath [ 0 ] != '/' ) { throw new URIException ( URIException . PARSING , "not absolute path" ) ; } if ( ! validate ( escapedPath , abs_path ) ) { throw new URIException ( URIException . ESCAPING , "escaped absolute path not valid" ) ; } _path = escapedPath ; } else if ( _is_rel_path ) { int at = indexFirstOf ( escapedPath , '/' ) ; if ( at == 0 ) { throw new URIException ( URIException . PARSING , "incorrect path" ) ; } if ( at > 0 && ! validate ( escapedPath , 0 , at - 1 , rel_segment ) && ! validate ( escapedPath , at , - 1 , abs_path ) || at < 0 && ! validate ( escapedPath , 0 , - 1 , rel_segment ) ) { throw new URIException ( URIException . ESCAPING , "escaped relative path not valid" ) ; } _path = escapedPath ; } else if ( _is_opaque_part ) { if ( ! uric_no_slash . get ( escapedPath [ 0 ] ) && ! validate ( escapedPath , 1 , - 1 , uric ) ) { throw new URIException ( URIException . ESCAPING , "escaped opaque part not valid" ) ; } _opaque = escapedPath ; } else { throw new URIException ( URIException . PARSING , "incorrect path" ) ; } setURI ( ) ; }
Set the raw - escaped path .
20,886
public void setEscapedPath ( String escapedPath ) throws URIException { if ( escapedPath == null ) { _path = _opaque = null ; setURI ( ) ; return ; } setRawPath ( escapedPath . toCharArray ( ) ) ; }
Set the escaped path .
20,887
public void setPath ( String path ) throws URIException { if ( path == null || path . length ( ) == 0 ) { _path = _opaque = ( path == null ) ? null : path . toCharArray ( ) ; setURI ( ) ; return ; } String charset = getProtocolCharset ( ) ; if ( _is_net_path || _is_abs_path ) { _path = encode ( path , allowed_abs_path , charset ) ; } else if ( _is_rel_path ) { StringBuffer buff = new StringBuffer ( path . length ( ) ) ; int at = path . indexOf ( '/' ) ; if ( at == 0 ) { throw new URIException ( URIException . PARSING , "incorrect relative path" ) ; } if ( at > 0 ) { buff . append ( encode ( path . substring ( 0 , at ) , allowed_rel_path , charset ) ) ; buff . append ( encode ( path . substring ( at ) , allowed_abs_path , charset ) ) ; } else { buff . append ( encode ( path , allowed_rel_path , charset ) ) ; } _path = buff . toString ( ) . toCharArray ( ) ; } else if ( _is_opaque_part ) { StringBuffer buf = new StringBuffer ( ) ; buf . insert ( 0 , encode ( path . substring ( 0 , 1 ) , uric_no_slash , charset ) ) ; buf . insert ( 1 , encode ( path . substring ( 1 ) , uric , charset ) ) ; _opaque = buf . toString ( ) . toCharArray ( ) ; } else { throw new URIException ( URIException . PARSING , "incorrect path" ) ; } setURI ( ) ; }
Set the path .
20,888
protected char [ ] resolvePath ( char [ ] basePath , char [ ] relPath ) throws URIException { String base = ( basePath == null ) ? "" : new String ( basePath ) ; if ( relPath == null || relPath . length == 0 ) { return normalize ( basePath ) ; } else if ( relPath [ 0 ] == '/' ) { return normalize ( relPath ) ; } else { int at = base . lastIndexOf ( '/' ) ; if ( at != - 1 ) { basePath = base . substring ( 0 , at + 1 ) . toCharArray ( ) ; } StringBuffer buff = new StringBuffer ( base . length ( ) + relPath . length ) ; buff . append ( ( at != - 1 ) ? base . substring ( 0 , at + 1 ) : "/" ) ; buff . append ( relPath ) ; return normalize ( buff . toString ( ) . toCharArray ( ) ) ; } }
Resolve the base and relative path .
20,889
public String getEscapedCurrentHierPath ( ) throws URIException { char [ ] path = getRawCurrentHierPath ( ) ; return ( path == null ) ? null : new String ( path ) ; }
Get the escaped current hierarchy level .
20,890
public String getCurrentHierPath ( ) throws URIException { char [ ] path = getRawCurrentHierPath ( ) ; return ( path == null ) ? null : decode ( path , getProtocolCharset ( ) ) ; }
Get the current hierarchy level .
20,891
public char [ ] getRawName ( ) { if ( _path == null ) { return null ; } int at = 0 ; for ( int i = _path . length - 1 ; i >= 0 ; i -- ) { if ( _path [ i ] == '/' ) { at = i + 1 ; break ; } } int len = _path . length - at ; char [ ] basename = new char [ len ] ; System . arraycopy ( _path , at , basename , 0 , len ) ; return basename ; }
Get the raw - escaped basename of the path .
20,892
public String getName ( ) throws URIException { char [ ] basename = getRawName ( ) ; return ( basename == null ) ? null : decode ( getRawName ( ) , getProtocolCharset ( ) ) ; }
Get the basename of the path .
20,893
public char [ ] getRawPathQuery ( ) { if ( _path == null && _query == null ) { return null ; } StringBuffer buff = new StringBuffer ( ) ; if ( _path != null ) { buff . append ( _path ) ; } if ( _query != null ) { buff . append ( '?' ) ; buff . append ( _query ) ; } return buff . toString ( ) . toCharArray ( ) ; }
Get the raw - escaped path and query .
20,894
public String getPathQuery ( ) throws URIException { char [ ] rawPathQuery = getRawPathQuery ( ) ; return ( rawPathQuery == null ) ? null : decode ( rawPathQuery , getProtocolCharset ( ) ) ; }
Get the path and query .
20,895
public void setRawQuery ( char [ ] escapedQuery ) throws URIException { if ( escapedQuery == null || escapedQuery . length == 0 ) { _query = escapedQuery ; setURI ( ) ; return ; } escapedQuery = removeFragmentIdentifier ( escapedQuery ) ; if ( ! validate ( escapedQuery , query ) ) { throw new URIException ( URIException . ESCAPING , "escaped query not valid" ) ; } _query = escapedQuery ; setURI ( ) ; }
Set the raw - escaped query .
20,896
public void setEscapedQuery ( String escapedQuery ) throws URIException { if ( escapedQuery == null ) { _query = null ; setURI ( ) ; return ; } setRawQuery ( escapedQuery . toCharArray ( ) ) ; }
Set the escaped query string .
20,897
public void setRawFragment ( char [ ] escapedFragment ) throws URIException { if ( escapedFragment == null || escapedFragment . length == 0 ) { _fragment = escapedFragment ; hash = 0 ; return ; } if ( ! validate ( escapedFragment , fragment ) ) { throw new URIException ( URIException . ESCAPING , "escaped fragment not valid" ) ; } _fragment = escapedFragment ; hash = 0 ; }
Set the raw - escaped fragment .
20,898
public void setEscapedFragment ( String escapedFragment ) throws URIException { if ( escapedFragment == null ) { _fragment = null ; hash = 0 ; return ; } setRawFragment ( escapedFragment . toCharArray ( ) ) ; }
Set the escaped fragment string .
20,899
public void setFragment ( String fragment ) throws URIException { if ( fragment == null || fragment . length ( ) == 0 ) { _fragment = ( fragment == null ) ? null : fragment . toCharArray ( ) ; hash = 0 ; return ; } _fragment = encode ( fragment , allowed_fragment , getProtocolCharset ( ) ) ; hash = 0 ; }
Set the fragment .