idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
20,300
public static Jwt decode ( String token ) { int firstPeriod = token . indexOf ( '.' ) ; int lastPeriod = token . lastIndexOf ( '.' ) ; if ( firstPeriod <= 0 || lastPeriod <= firstPeriod ) { throw new IllegalArgumentException ( "JWT must have 3 tokens" ) ; } CharBuffer buffer = CharBuffer . wrap ( token , 0 , firstPerio...
Creates a token from an encoded token string .
20,301
public byte [ ] bytes ( ) { return concat ( b64UrlEncode ( header . bytes ( ) ) , JwtHelper . PERIOD , b64UrlEncode ( content ) , JwtHelper . PERIOD , b64UrlEncode ( crypto ) ) ; }
Allows retrieval of the full token .
20,302
protected String extractHeaderToken ( HttpServletRequest request ) { Enumeration < String > headers = request . getHeaders ( "Authorization" ) ; while ( headers . hasMoreElements ( ) ) { String value = headers . nextElement ( ) ; if ( ( value . toLowerCase ( ) . startsWith ( OAuth2AccessToken . BEARER_TYPE . toLowerCas...
Extract the OAuth bearer token from a header .
20,303
protected boolean isExpired ( OAuthProviderTokenImpl authToken ) { if ( authToken . isAccessToken ( ) ) { if ( ( authToken . getTimestamp ( ) + ( getAccessTokenValiditySeconds ( ) * 1000L ) ) < System . currentTimeMillis ( ) ) { return true ; } } else { if ( ( authToken . getTimestamp ( ) + ( getRequestTokenValiditySec...
Whether the auth token is expired .
20,304
private boolean matchQueryParams ( MultiValueMap < String , String > registeredRedirectUriQueryParams , MultiValueMap < String , String > requestedRedirectUriQueryParams ) { Iterator < String > iter = registeredRedirectUriQueryParams . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { String key = iter . next ...
Checks whether the registered redirect uri query params key and values contains match the requested set
20,305
private boolean isEqual ( String str1 , String str2 ) { if ( StringUtils . isEmpty ( str1 ) && StringUtils . isEmpty ( str2 ) ) { return true ; } else if ( ! StringUtils . isEmpty ( str1 ) ) { return str1 . equals ( str2 ) ; } else { return false ; } }
Compares two strings but treats empty string or null equal
20,306
protected boolean hostMatches ( String registered , String requested ) { if ( matchSubdomains ) { return registered . equals ( requested ) || requested . endsWith ( "." + registered ) ; } return registered . equals ( requested ) ; }
Check if host matches the registered value .
20,307
public static String oauthEncode ( String value ) { if ( value == null ) { return "" ; } try { return new String ( URLCodec . encodeUrl ( SAFE_CHARACTERS , value . getBytes ( "UTF-8" ) ) , "US-ASCII" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
Encode the specified value .
20,308
public static String oauthDecode ( String value ) throws DecoderException { if ( value == null ) { return "" ; } try { return new String ( URLCodec . decodeUrl ( value . getBytes ( "US-ASCII" ) ) , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
Decode the specified value .
20,309
public ProviderConfiguration discover ( ) { Map responseAttributes = this . restTemplate . getForObject ( this . providerLocation , Map . class ) ; ProviderConfiguration . Builder builder = new ProviderConfiguration . Builder ( ) ; builder . issuer ( ( String ) responseAttributes . get ( ISSUER_ATTR_NAME ) ) ; builder ...
Discover the provider configuration information .
20,310
public Map < String , String > getKey ( ) { Map < String , String > result = new LinkedHashMap < String , String > ( ) ; result . put ( "alg" , signer . algorithm ( ) ) ; result . put ( "value" , verifierKey ) ; return result ; }
Get the verification key for the token signatures .
20,311
public OAuth2Request createOAuth2Request ( Map < String , String > parameters ) { return new OAuth2Request ( parameters , getClientId ( ) , authorities , approved , getScope ( ) , resourceIds , redirectUri , responseTypes , extensions ) ; }
Update the request parameters and return a new object with the same properties except the parameters .
20,312
public String getGrantType ( ) { if ( getRequestParameters ( ) . containsKey ( OAuth2Utils . GRANT_TYPE ) ) { return getRequestParameters ( ) . get ( OAuth2Utils . GRANT_TYPE ) ; } if ( getRequestParameters ( ) . containsKey ( OAuth2Utils . RESPONSE_TYPE ) ) { String response = getRequestParameters ( ) . get ( OAuth2Ut...
Tries to discover the grant type requested for the token associated with this request .
20,313
public String sign ( String signatureBaseString ) { try { Mac mac = Mac . getInstance ( MAC_NAME ) ; mac . init ( key ) ; byte [ ] text = signatureBaseString . getBytes ( "UTF-8" ) ; byte [ ] signatureBytes = mac . doFinal ( text ) ; signatureBytes = Base64 . encodeBase64 ( signatureBytes ) ; String signature = new Str...
Sign the signature base string . The signature is the digest octet string first base64 - encoded per RFC2045 section 6 . 8 then URL - encoded per OAuth Parameter Encoding .
20,314
public Authentication createAuthentication ( HttpServletRequest request , ConsumerAuthentication authentication , OAuthAccessProviderToken authToken ) { if ( authToken != null ) { Authentication userAuthentication = authToken . getUserAuthentication ( ) ; if ( userAuthentication instanceof AbstractAuthenticationToken )...
Default implementation returns the user authentication associated with the auth token if the token is provided . Otherwise the consumer authentication is returned .
20,315
protected boolean parametersAreAdequate ( Map < String , String > oauthParams ) { return oauthParams . containsKey ( OAuthConsumerParameter . oauth_consumer_key . toString ( ) ) ; }
By default OAuth parameters are adequate if a consumer key is present .
20,316
protected void validateSignature ( ConsumerAuthentication authentication ) throws AuthenticationException { SignatureSecret secret = authentication . getConsumerDetails ( ) . getSignatureSecret ( ) ; String token = authentication . getConsumerCredentials ( ) . getToken ( ) ; OAuthProviderToken authToken = null ; if ( t...
Validate the signature of the request given the authentication request .
20,317
protected void validateOAuthParams ( ConsumerDetails consumerDetails , Map < String , String > oauthParams ) throws InvalidOAuthParametersException { String version = oauthParams . get ( OAuthConsumerParameter . oauth_version . toString ( ) ) ; if ( ( version != null ) && ( ! "1.0" . equals ( version ) ) ) { throw new ...
Validates the OAuth parameters for the given consumer . Base implementation validates only those parameters that are required for all OAuth requests . This includes the nonce and timestamp but not the signature .
20,318
protected void fail ( HttpServletRequest request , HttpServletResponse response , AuthenticationException failure ) throws IOException , ServletException { SecurityContextHolder . getContext ( ) . setAuthentication ( null ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( failure ) ; } authenticationEntryPoint . comme...
Common logic for OAuth failed .
20,319
protected boolean requiresAuthentication ( HttpServletRequest request , HttpServletResponse response , FilterChain filterChain ) { String uri = request . getRequestURI ( ) ; int pathParamIndex = uri . indexOf ( ';' ) ; if ( pathParamIndex > 0 ) { uri = uri . substring ( 0 , pathParamIndex ) ; } if ( "" . equals ( reque...
Whether this filter is configured to process the specified request .
20,320
protected boolean skipProcessing ( HttpServletRequest request ) { return ( ( request . getAttribute ( OAUTH_PROCESSING_HANDLED ) != null ) && ( Boolean . TRUE . equals ( request . getAttribute ( OAUTH_PROCESSING_HANDLED ) ) ) ) ; }
Whether to skip processing for the specified request .
20,321
public void setAllowedMethods ( List < String > allowedMethods ) { this . allowedMethods . clear ( ) ; if ( allowedMethods != null ) { for ( String allowedMethod : allowedMethods ) { this . allowedMethods . add ( allowedMethod . toUpperCase ( ) ) ; } } }
The allowed set of HTTP methods .
20,322
protected Map < String , String > parseHeaderParameters ( HttpServletRequest request ) { String header = null ; Enumeration < String > headers = request . getHeaders ( "Authorization" ) ; while ( headers . hasMoreElements ( ) ) { String value = headers . nextElement ( ) ; if ( ( value . toLowerCase ( ) . startsWith ( "...
Parse the OAuth header parameters . The parameters will be oauth - decoded .
20,323
protected String normalizeUrl ( String url ) { try { URL requestURL = new URL ( url ) ; StringBuilder normalized = new StringBuilder ( requestURL . getProtocol ( ) . toLowerCase ( ) ) . append ( "://" ) . append ( requestURL . getHost ( ) . toLowerCase ( ) ) ; if ( ( requestURL . getPort ( ) >= 0 ) && ( requestURL . ge...
Normalize the URL for use in the signature . The OAuth spec says the URL protocol and host are to be lower - case and the query and fragments are to be stripped .
20,324
protected OAuthProviderToken createOAuthToken ( ConsumerAuthentication authentication ) { return getTokenServices ( ) . createUnauthorizedRequestToken ( authentication . getConsumerDetails ( ) . getConsumerKey ( ) , authentication . getOAuthParameters ( ) . get ( OAuthConsumerParameter . oauth_callback . toString ( ) )...
Create the OAuth token for the specified consumer key .
20,325
protected Map < String , Object > decode ( String token ) { Map < String , String > headers = this . jwtHeaderConverter . convert ( token ) ; String keyIdHeader = headers . get ( KEY_ID ) ; if ( keyIdHeader == null ) { throw new InvalidTokenException ( "Invalid JWT/JWS: " + KEY_ID + " is a required JOSE Header" ) ; } J...
Decodes and validates the supplied JWT followed by signature verification before returning the Claims from the JWT Payload .
20,326
public URL configureURLForProtectedAccess ( URL url , OAuthConsumerToken accessToken , String httpMethod , Map < String , String > additionalParameters ) throws OAuthRequestFailedException { return configureURLForProtectedAccess ( url , accessToken , getProtectedResourceDetailsService ( ) . loadProtectedResourceDetails...
Create a configured URL . If the HTTP method to access the resource is POST or PUT and the Authorization header isn t supported then the OAuth parameters will be expected to be sent in the body of the request . Otherwise you can assume that the given URL is ready to be used without further work .
20,327
protected URL configureURLForProtectedAccess ( URL url , OAuthConsumerToken requestToken , ProtectedResourceDetails details , String httpMethod , Map < String , String > additionalParameters ) { String file ; if ( ! "POST" . equalsIgnoreCase ( httpMethod ) && ! "PUT" . equalsIgnoreCase ( httpMethod ) && ! details . isA...
Internal use of configuring the URL for protected access the resource details already having been loaded .
20,328
protected String findValidHeaderValue ( Set < CharSequence > paramValues ) { String selectedValue = null ; if ( paramValues != null && ! paramValues . isEmpty ( ) ) { CharSequence value = paramValues . iterator ( ) . next ( ) ; if ( ! ( value instanceof QueryParameterValue ) ) { selectedValue = value . toString ( ) ; }...
Finds a valid header value that is valid for the OAuth header .
20,329
protected OAuthConsumerToken getTokenFromProvider ( ProtectedResourceDetails details , URL tokenURL , String httpMethod , OAuthConsumerToken requestToken , Map < String , String > additionalParameters ) { boolean isAccessToken = requestToken != null ; if ( ! isAccessToken ) { requestToken = new OAuthConsumerToken ( ) ;...
Get the consumer token with the given parameters and URL . The determination of whether the retrieved token is an access token depends on whether a request token is provided .
20,330
protected String urlDecode ( String token ) { try { return URLDecoder . decode ( token , "utf-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
URL - decode a token .
20,331
protected HttpURLConnection openConnection ( URL requestTokenURL ) { try { HttpURLConnection connection = ( HttpURLConnection ) requestTokenURL . openConnection ( selectProxy ( requestTokenURL ) ) ; connection . setConnectTimeout ( getConnectionTimeout ( ) ) ; connection . setReadTimeout ( getReadTimeout ( ) ) ; return...
Open a connection to the given URL .
20,332
protected Proxy selectProxy ( URL requestTokenURL ) { try { List < Proxy > selectedProxies = getProxySelector ( ) . select ( requestTokenURL . toURI ( ) ) ; return selectedProxies . isEmpty ( ) ? Proxy . NO_PROXY : selectedProxies . get ( 0 ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( e )...
Selects a proxy for the given URL .
20,333
protected String getSignatureBaseString ( Map < String , Set < CharSequence > > oauthParams , URL requestURL , String httpMethod ) { TreeMap < String , TreeSet < String > > sortedParameters = new TreeMap < String , TreeSet < String > > ( ) ; for ( Map . Entry < String , Set < CharSequence > > param : oauthParams . entr...
Get the signature base string for the specified parameters . It is presumed the parameters are NOT OAuth - encoded .
20,334
protected void redirectUser ( UserRedirectRequiredException e , HttpServletRequest request , HttpServletResponse response ) throws IOException { String redirectUri = e . getRedirectUri ( ) ; UriComponentsBuilder builder = UriComponentsBuilder . fromHttpUrl ( redirectUri ) ; Map < String , String > requestParams = e . g...
Redirect the user according to the specified exception .
20,335
protected String calculateCurrentUri ( HttpServletRequest request ) throws UnsupportedEncodingException { ServletUriComponentsBuilder builder = ServletUriComponentsBuilder . fromRequest ( request ) ; String queryString = request . getQueryString ( ) ; boolean legalSpaces = queryString != null && queryString . contains ...
Calculate the current URI given the request .
20,336
public void tokenEndpointAuthenticationFilters ( List < Filter > filters ) { Assert . notNull ( filters , "Custom authentication filter list must not be null" ) ; this . tokenEndpointAuthenticationFilters = new ArrayList < Filter > ( filters ) ; }
Sets a new list of custom authentication filters for the TokenEndpoint . Filters will be set upstream of the default BasicAuthenticationFilter .
20,337
public int vote ( Authentication authentication , Object object , Collection < ConfigAttribute > configAttributes ) { int result = ACCESS_ABSTAIN ; if ( authentication . getDetails ( ) instanceof OAuthAuthenticationDetails ) { OAuthAuthenticationDetails details = ( OAuthAuthenticationDetails ) authentication . getDetai...
Votes on giving access to the specified authentication based on the security attributes .
20,338
public AdminController adminController ( TokenStore tokenStore , @ Qualifier ( "consumerTokenServices" ) ConsumerTokenServices tokenServices , SparklrUserApprovalHandler userApprovalHandler ) { AdminController adminController = new AdminController ( ) ; adminController . setTokenStore ( tokenStore ) ; adminController ....
N . B . the
20,339
public boolean revokeApprovals ( Collection < Approval > approvals ) { boolean success = true ; for ( Approval approval : approvals ) { Collection < OAuth2AccessToken > tokens = store . findTokensByClientIdAndUserName ( approval . getClientId ( ) , approval . getUserId ( ) ) ; for ( OAuth2AccessToken token : tokens ) {...
Revoke all tokens that match the client and user in the approvals supplied .
20,340
public Collection < Approval > getApprovals ( String userId , String clientId ) { Collection < Approval > result = new HashSet < Approval > ( ) ; Collection < OAuth2AccessToken > tokens = store . findTokensByClientIdAndUserName ( clientId , userId ) ; for ( OAuth2AccessToken token : tokens ) { OAuth2Authentication auth...
Extract the implied approvals from any tokens associated with the user and client id supplied .
20,341
protected ProtectedResourceDetails checkForResourceThatNeedsAuthorization ( Exception ex ) throws ServletException , IOException { Throwable [ ] causeChain = getThrowableAnalyzer ( ) . determineCauseChain ( ex ) ; AccessTokenRequiredException ase = ( AccessTokenRequiredException ) getThrowableAnalyzer ( ) . getFirstThr...
Check the given exception for the resource that needs authorization . If the exception was not thrown because a resource needed authorization then rethrow the exception .
20,342
protected String getUserAuthorizationRedirectURL ( ProtectedResourceDetails details , OAuthConsumerToken requestToken , String callbackURL ) { try { String baseURL = details . getUserAuthorizationURL ( ) ; StringBuilder builder = new StringBuilder ( baseURL ) ; char appendChar = baseURL . indexOf ( '?' ) < 0 ? '?' : '&...
Get the URL to which to redirect the user for authorization of protected resources .
20,343
private OAuth2Authentication createRefreshedAuthentication ( OAuth2Authentication authentication , TokenRequest request ) { OAuth2Authentication narrowed = authentication ; Set < String > scope = request . getScope ( ) ; OAuth2Request clientAuth = authentication . getOAuth2Request ( ) . refresh ( request ) ; if ( scope...
Create a refreshed authentication .
20,344
protected int getAccessTokenValiditySeconds ( OAuth2Request clientAuth ) { if ( clientDetailsService != null ) { ClientDetails client = clientDetailsService . loadClientByClientId ( clientAuth . getClientId ( ) ) ; Integer validity = client . getAccessTokenValiditySeconds ( ) ; if ( validity != null ) { return validity...
The access token validity period in seconds
20,345
protected int getRefreshTokenValiditySeconds ( OAuth2Request clientAuth ) { if ( clientDetailsService != null ) { ClientDetails client = clientDetailsService . loadClientByClientId ( clientAuth . getClientId ( ) ) ; Integer validity = client . getRefreshTokenValiditySeconds ( ) ; if ( validity != null ) { return validi...
The refresh token validity period in seconds
20,346
public void validateNonce ( ConsumerDetails consumerDetails , long timestamp , String nonce ) throws AuthenticationException { long nowSeconds = ( System . currentTimeMillis ( ) / 1000 ) ; if ( ( nowSeconds - timestamp ) > getValidityWindowSeconds ( ) ) { throw new CredentialsExpiredException ( "Expired timestamp." ) ;...
we ll default to a 12 - hour validity window .
20,347
public void verify ( String signatureBaseString , String signature ) throws InvalidSignatureException { if ( this . encoder != null ) { if ( ! this . encoder . isPasswordValid ( this . secret , signature , this . salt ) ) { throw new InvalidSignatureException ( "Invalid signature for signature method " + getName ( ) ) ...
Validates that the signature is the same as the secret .
20,348
public boolean hasAnyScope ( String ... scopes ) { boolean result = OAuth2ExpressionUtils . hasAnyScope ( authentication , scopes ) ; if ( ! result ) { missingScopes . addAll ( Arrays . asList ( scopes ) ) ; } return result ; }
Check if the current OAuth2 authentication has one of the scopes specified .
20,349
public boolean hasAnyScopeMatching ( String ... scopesRegex ) { boolean result = OAuth2ExpressionUtils . hasAnyScopeMatching ( authentication , scopesRegex ) ; if ( ! result ) { missingScopes . addAll ( Arrays . asList ( scopesRegex ) ) ; } return result ; }
Check if the current OAuth2 authentication has one of the scopes matching a specified regex expression .
20,350
public static PublicKey createPublicKey ( byte [ ] publicKey ) { if ( publicKey == null ) { return null ; } try { KeyFactory fac = KeyFactory . getInstance ( "RSA" ) ; EncodedKeySpec spec = new X509EncodedKeySpec ( publicKey ) ; return fac . generatePublic ( spec ) ; } catch ( NoSuchAlgorithmException e ) { throw new I...
Creates a public key from the X509 - encoded value of the given bytes .
20,351
private static byte [ ] base64Decode ( String value ) { if ( value == null ) { return null ; } try { return Base64 . decodeBase64 ( value . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
Utility method for decoding a base - 64 - encoded string .
20,352
public void addAdditionalInformation ( String key , String value ) { if ( this . additionalInformation == null ) { this . additionalInformation = new TreeMap < String , String > ( ) ; } this . additionalInformation . put ( key , value ) ; }
Add some additional information with this OAuth error .
20,353
public static OAuth2Exception create ( String errorCode , String errorMessage ) { if ( errorMessage == null ) { errorMessage = errorCode == null ? "OAuth Error" : errorCode ; } if ( INVALID_CLIENT . equals ( errorCode ) ) { return new InvalidClientException ( errorMessage ) ; } else if ( UNAUTHORIZED_CLIENT . equals ( ...
Creates the appropriate subclass of OAuth2Exception given the errorCode .
20,354
public URI getURI ( ) throws URIException { StringBuffer buffer = new StringBuffer ( ) ; if ( this . httphost != null ) { buffer . append ( this . httphost . getProtocol ( ) . getScheme ( ) ) ; buffer . append ( "://" ) ; buffer . append ( this . httphost . getHostName ( ) ) ; int port = this . httphost . getPort ( ) ;...
Returns the URI of the HTTP method
20,355
public void setURI ( URI uri ) throws URIException { if ( uri . isAbsoluteURI ( ) ) { this . httphost = new HttpHost ( uri ) ; } setPath ( uri . getPath ( ) == null ? "/" : uri . getEscapedPath ( ) ) ; setQueryString ( uri . getEscapedQuery ( ) ) ; }
Sets the URI for this method .
20,356
public void setHttp11 ( boolean http11 ) { if ( http11 ) { this . params . setVersion ( HttpVersion . HTTP_1_1 ) ; } else { this . params . setVersion ( HttpVersion . HTTP_1_0 ) ; } }
Sets whether version 1 . 1 of the HTTP protocol should be used per default .
20,357
public void setQueryString ( NameValuePair [ ] params ) { LOG . trace ( "enter HttpMethodBase.setQueryString(NameValuePair[])" ) ; queryString = EncodingUtil . formUrlEncode ( params , "UTF-8" ) ; }
Sets the query string of this HTTP method . The pairs are encoded as UTF - 8 characters . To use a different charset the parameters can be encoded manually using EncodingUtil and set as a single String .
20,358
public void setRequestHeader ( String headerName , String headerValue ) { Header header = new Header ( headerName , headerValue ) ; setRequestHeader ( header ) ; }
Set the specified request header overwriting any previous value . Note that header - name matching is case - insensitive .
20,359
public void setRequestHeader ( Header header ) { Header [ ] headers = getRequestHeaderGroup ( ) . getHeaders ( header . getName ( ) ) ; for ( int i = 0 ; i < headers . length ; i ++ ) { getRequestHeaderGroup ( ) . removeHeader ( headers [ i ] ) ; } getRequestHeaderGroup ( ) . addHeader ( header ) ; }
Sets the specified request header overwriting any previous value . Note that header - name matching is case insensitive .
20,360
private void checkExecuteConditions ( HttpState state , HttpConnection conn ) throws HttpException { if ( state == null ) { throw new IllegalArgumentException ( "HttpState parameter may not be null" ) ; } if ( conn == null ) { throw new IllegalArgumentException ( "HttpConnection parameter may not be null" ) ; } if ( th...
Tests if the this method is ready to be executed .
20,361
public void abort ( ) { if ( this . aborted ) { return ; } this . aborted = true ; HttpConnection conn = this . responseConnection ; if ( conn != null ) { conn . close ( ) ; } }
Aborts the execution of this method .
20,362
public void recycle ( ) { LOG . trace ( "enter HttpMethodBase.recycle()" ) ; releaseConnection ( ) ; path = null ; followRedirects = false ; doAuthentication = true ; queryString = null ; getRequestHeaderGroup ( ) . clear ( ) ; getResponseHeaderGroup ( ) . clear ( ) ; getResponseTrailerHeaderGroup ( ) . clear ( ) ; sta...
Recycles the HTTP method so that it can be used again . Note that all of the instance variables will be reset once this method has been called . This method will also release the connection being used by this HTTP method .
20,363
public void removeRequestHeader ( String headerName ) { Header [ ] headers = getRequestHeaderGroup ( ) . getHeaders ( headerName ) ; for ( int i = 0 ; i < headers . length ; i ++ ) { getRequestHeaderGroup ( ) . removeHeader ( headers [ i ] ) ; } }
Remove the request header associated with the given name . Note that header - name matching is case insensitive .
20,364
@ SuppressWarnings ( "deprecation" ) private CookieSpec getCookieSpec ( final HttpState state ) { if ( this . cookiespec == null ) { int i = state . getCookiePolicy ( ) ; if ( i == - 1 ) { this . cookiespec = CookiePolicy . getCookieSpec ( this . params . getCookiePolicy ( ) ) ; } else { this . cookiespec = CookiePolic...
Returns the actual cookie policy
20,365
private void putAllCookiesInASingleHeader ( String host , CookieSpec matcher , Cookie [ ] cookies ) { LOG . trace ( "enter putAllCookiesInASingleHeader(String host, CookieSpec matcher, Cookie[] cookies)" ) ; HashMap < String , Cookie > mergedCookies = new HashMap < String , Cookie > ( ) ; Header [ ] cookieLineHeaders =...
Put all the cookies in a single header line .
20,366
static List < Cookie > parseCookieHeader ( String host , String cookieHeaderValue ) { if ( StringUtils . isEmpty ( cookieHeaderValue ) ) { return Collections . emptyList ( ) ; } String [ ] cookies = cookieHeaderValue . split ( ";" ) ; List < Cookie > cookiesList = new ArrayList < Cookie > ( ) ; for ( String cookie : co...
Parse a cookie header to return a list of cookies .
20,367
protected static String generateRequestLine ( HttpConnection connection , String name , String requestPath , String query , String version ) { LOG . trace ( "enter HttpMethodBase.generateRequestLine(HttpConnection, " + "String, String, String, String)" ) ; StringBuffer buf = new StringBuffer ( ) ; buf . append ( name )...
Generates HTTP request line according to the specified attributes .
20,368
private String getRequestLine ( HttpConnection conn ) { return HttpMethodBase . generateRequestLine ( conn , getName ( ) , getPath ( ) , getQueryString ( ) , this . effectiveVersion . toString ( ) ) ; }
Returns the request line .
20,369
private static boolean canResponseHaveBody ( int status ) { LOG . trace ( "enter HttpMethodBase.canResponseHaveBody(int)" ) ; boolean result = true ; if ( ( status >= 100 && status <= 199 ) || ( status == 204 ) || ( status == 304 ) ) { result = false ; } return result ; }
Per RFC 2616 section 4 . 3 some response can never contain a message body .
20,370
protected void responseBodyConsumed ( ) { responseStream = null ; if ( responseConnection != null ) { responseConnection . setLastResponseInputStream ( null ) ; if ( shouldCloseConnection ( responseConnection ) ) { responseConnection . close ( ) ; } else { try { if ( responseConnection . isResponseAvailable ( ) ) { boo...
A response has been consumed .
20,371
protected void addSeed ( URI uri , String method ) { String visitedURI ; try { visitedURI = URLCanonicalizer . buildCleanedParametersURIRepresentation ( uri , spider . getSpiderParam ( ) . getHandleParameters ( ) , spider . getSpiderParam ( ) . isHandleODataParametersVisited ( ) ) ; } catch ( URIException e ) { return ...
Adds a new seed if it wasn t already processed .
20,372
public void addFetchFilter ( FetchFilter filter ) { log . debug ( "Loading fetch filter: " + filter . getClass ( ) . getSimpleName ( ) ) ; fetchFilters . add ( filter ) ; }
Adds a new fetch filter to the spider .
20,373
public void addParseFilter ( ParseFilter filter ) { log . debug ( "Loading parse filter: " + filter . getClass ( ) . getSimpleName ( ) ) ; parseFilters . add ( filter ) ; }
Adds the parse filter to the spider controller .
20,374
public void reset ( ) { visitedGet . clear ( ) ; visitedPost . clear ( ) ; for ( SpiderParser parser : parsers ) { parser . removeSpiderParserListener ( this ) ; } }
Clears the previous process .
20,375
private boolean arrayKeyValueExists ( String key , String value ) { if ( visitedPost . containsKey ( key ) ) { for ( String s : visitedPost . get ( key ) ) { if ( s . equals ( value ) ) { return true ; } } } return false ; }
Checks whether the value exists in an ArrayList of certain key .
20,376
public void setSummaryContent ( String content ) { Logger . getRootLogger ( ) . info ( "New summary: " + content ) ; summaryArea . setText ( "<html><b>" + summaryTitleText + "</b><br/><br/>" + content + "</html>" ) ; }
Sets the summary content .
20,377
private JSlider getSliderHostPerScan ( ) { if ( sliderHostPerScan == null ) { sliderHostPerScan = new JSlider ( ) ; sliderHostPerScan . setMaximum ( 5 ) ; sliderHostPerScan . setMinimum ( 1 ) ; sliderHostPerScan . setMinorTickSpacing ( 1 ) ; sliderHostPerScan . setPaintTicks ( true ) ; sliderHostPerScan . setPaintLabel...
This method initializes sliderHostPerScan
20,378
private JSlider getSliderThreadsPerHost ( ) { if ( sliderThreadsPerHost == null ) { sliderThreadsPerHost = new PositiveValuesSlider ( Constant . MAX_THREADS_PER_SCAN ) ; sliderThreadsPerHost . addChangeListener ( new ChangeListener ( ) { public void stateChanged ( ChangeEvent e ) { setLabelThreadsPerHostValue ( getSlid...
This method initializes sliderThreadsPerHost
20,379
private static JScrollPane createScrollableTreeAddOnsNotRunnable ( final AddOnCollection availableAddOns , AddOn ... addOnsNotRunnable ) { AddOnSearcher addOnSearcher = new AddOnSearcher ( ) { public AddOn searchAddOn ( String id ) { return availableAddOns . getAddOn ( id ) ; } } ; DefaultMutableTreeNode rootNode = new...
Creates a scrollable tree with the given add - ons as root nodes and its issues as child nodes .
20,380
private void applyConnectionParams ( final HttpMethod method ) throws IOException { int timeout = 0 ; Object param = method . getParams ( ) . getParameter ( HttpMethodParams . SO_TIMEOUT ) ; if ( param == null ) { param = this . conn . getParams ( ) . getParameter ( HttpConnectionParams . SO_TIMEOUT ) ; } if ( param !=...
Applies connection parameters specified for a given method
20,381
private boolean executeConnect ( ) throws IOException , HttpException { this . connectMethod = new ConnectMethod ( this . hostConfiguration ) ; this . connectMethod . getParams ( ) . setDefaults ( this . hostConfiguration . getParams ( ) ) ; String agent = ( String ) getParams ( ) . getParameter ( PARAM_DEFAULT_USER_AG...
Executes a ConnectMethod to establish a tunneled connection .
20,382
private boolean processRedirectResponse ( final HttpMethod method ) throws RedirectException { Header locationHeader = method . getResponseHeader ( "location" ) ; if ( locationHeader == null ) { LOG . error ( "Received redirect response " + method . getStatusCode ( ) + " but no location header" ) ; return false ; } Str...
Process the redirect response .
20,383
private boolean processAuthenticationResponse ( final HttpMethod method ) { LOG . trace ( "enter HttpMethodBase.processAuthenticationResponse(" + "HttpState, HttpConnection)" ) ; try { switch ( method . getStatusCode ( ) ) { case HttpStatus . SC_UNAUTHORIZED : return processWWWAuthChallenge ( method ) ; case HttpStatus...
Processes a response that requires authentication
20,384
public boolean isSelectedPartially ( TreePath path ) { CheckedNode cn = nodesCheckingState . get ( path ) ; return cn . isSelected && cn . hasChildren && ! cn . allChildrenSelected ; }
Returns true in case that the node is selected has children but not all of them are selected
20,385
private void addSubtreeToCheckingStateTracking ( DefaultMutableTreeNode node ) { TreeNode [ ] path = node . getPath ( ) ; TreePath tp = new TreePath ( path ) ; CheckedNode cn = new CheckedNode ( false , node . getChildCount ( ) > 0 , false ) ; nodesCheckingState . put ( tp , cn ) ; for ( int i = 0 ; i < node . getChild...
Creating data structure of the current model for the checking mechanism
20,386
private JCheckBox getChkShowPassword ( ) { if ( chkShowPassword == null ) { chkShowPassword = new JCheckBox ( ) ; chkShowPassword . setText ( Constant . messages . getString ( "conn.options.proxy.auth.showpass" ) ) ; chkShowPassword . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionP...
This method initializes chkShowPassword
20,387
private JCheckBox getChkUseProxyChain ( ) { if ( chkUseProxyChain == null ) { chkUseProxyChain = new JCheckBox ( ) ; chkUseProxyChain . setText ( Constant . messages . getString ( "conn.options.useProxy" ) ) ; chkUseProxyChain . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerform...
This method initializes chkUseProxyChain
20,388
private JCheckBox getChkProxyChainAuth ( ) { if ( chkProxyChainAuth == null ) { chkProxyChainAuth = new JCheckBox ( ) ; chkProxyChainAuth . setText ( Constant . messages . getString ( "conn.options.proxy.auth.required" ) ) ; chkProxyChainAuth . addActionListener ( new java . awt . event . ActionListener ( ) { public vo...
This method initializes chkProxyChainAuth
20,389
public static void addFile ( String s ) throws IOException { File f = new File ( s ) ; addFile ( f ) ; }
Add file to CLASSPATH
20,390
public static void addURL ( URL u ) throws IOException { if ( ! ( ClassLoader . getSystemClassLoader ( ) instanceof URLClassLoader ) ) { return ; } URLClassLoader sysLoader = ( URLClassLoader ) ClassLoader . getSystemClassLoader ( ) ; URL [ ] urls = sysLoader . getURLs ( ) ; for ( int i = 0 ; i < urls . length ; i ++ )...
Add URL to CLASSPATH
20,391
protected JComboBox < SessionManagementMethodType > getSessionManagementMethodsComboBox ( ) { if ( sessionManagementMethodsComboBox == null ) { Vector < SessionManagementMethodType > methods = new Vector < > ( extension . getSessionManagementMethodTypes ( ) ) ; sessionManagementMethodsComboBox = new JComboBox < > ( met...
Gets the session management methods combo box .
20,392
private JPanel getConfigContainerPanel ( ) { if ( configContainerPanel == null ) { configContainerPanel = new JPanel ( new BorderLayout ( ) ) ; configContainerPanel . setBorder ( javax . swing . BorderFactory . createTitledBorder ( null , Constant . messages . getString ( "sessionmanagement.panel.config.title" ) , java...
Gets the configuration container panel .
20,393
private static < T > List < T > unmodifiableList ( List < T > list ) { if ( list == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( list ) ; }
Gets an unmodifiable list from the given list .
20,394
private static void warnAddOnsAndExtensionsNoLongerRunnable ( ) { final AddOnLoader addOnLoader = ExtensionFactory . getAddOnLoader ( ) ; List < String > idsAddOnsNoLongerRunning = addOnLoader . getIdsAddOnsWithRunningIssuesSinceLastRun ( ) ; if ( idsAddOnsNoLongerRunning . isEmpty ( ) ) { return ; } List < AddOn > add...
Warns through a dialogue about add - ons and extensions that are no longer runnable because of changes in its dependencies .
20,395
private static boolean isFirstTime ( ) { Path acceptedLicenseFile = Paths . get ( Constant . getInstance ( ) . ACCEPTED_LICENSE ) ; return Files . notExists ( acceptedLicenseFile ) ; }
Tells whether or not ZAP is being started for first time . It does so by checking if the license was not yet been accepted .
20,396
private void setDefaultList ( ) { final String defaultListArray [ ] [ ] = { { "^.*\\.(?:gif|jpe?g|png|ico|icns|bmp)$" , "Extension - Image (ends with .extension)" , "false" } , { "^.*\\.(?:mp[34]|mpe?g|m4[ap]|aac|avi|mov|wmv|og[gav])$" , "Extension - Audio/Video (ends with .extension)" , "false" } , { "^.*\\.(?:pdf|doc...
Fills in the list of default regexs to ignore . In a future version this could be read from a system - wide default HierarchicalConfiguration xml config file instead or even a HierarchicalConfiguration string directly embedded in this file .
20,397
private GenericScanner2 getSpiderScan ( JSONObject params ) throws ApiException { GenericScanner2 spiderScan ; int id = getParam ( params , PARAM_SCAN_ID , - 1 ) ; if ( id == - 1 ) { spiderScan = extension . getLastScan ( ) ; } else { spiderScan = extension . getScan ( id ) ; } if ( spiderScan == null ) { throw new Api...
Returns the specified GenericScanner2 or the last scan available .
20,398
public void setUseSystemsLocaleForFormat ( boolean useSystemsLocale ) { if ( useSystemsLocaleForFormat != useSystemsLocale ) { useSystemsLocaleForFormat = useSystemsLocale ; getConfig ( ) . setProperty ( USE_SYSTEMS_LOCALE_FOR_FORMAT_KEY , useSystemsLocaleForFormat ) ; } }
Sets whether or not the system s locale should be used for formatting .
20,399
public boolean matches ( String domain ) { if ( pattern != null ) { return pattern . matcher ( domain ) . matches ( ) ; } return this . domain . equals ( domain ) ; }
Tells whether or not the given domain is considered always in scope .