idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
28,300 | public static byte getPropertyAsByte ( final String name , final byte defaultValue ) { if ( PropertiesManager . props == null ) loadProps ( ) ; byte returnValue = defaultValue ; try { returnValue = getPropertyAsByte ( name ) ; } catch ( Throwable t ) { log . error ( "Could not retrieve or parse as byte property [" + na... | Get the value of the given property as a byte specifying a fallback default value . If for any reason we are unable to lookup the desired property this method returns the supplied default value . This error handling behavior makes this method suitable for calling from static initializers . |
28,301 | public static Version parseVersion ( String versionString ) { final Matcher versionMatcher = VERSION_PATTERN . matcher ( versionString ) ; if ( ! versionMatcher . matches ( ) ) { return null ; } final int major = Integer . parseInt ( versionMatcher . group ( 1 ) ) ; final int minor = Integer . parseInt ( versionMatcher... | Parse a version string into a Version object if the string doesn t match the pattern null is returned . |
28,302 | public static Version . Field getMostSpecificMatchingField ( Version v1 , Version v2 ) { if ( v1 . getMajor ( ) != v2 . getMajor ( ) ) { return null ; } if ( v1 . getMinor ( ) != v2 . getMinor ( ) ) { return Version . Field . MAJOR ; } if ( v1 . getPatch ( ) != v2 . getPatch ( ) ) { return Version . Field . MINOR ; } f... | Determine how much of two versions match . Returns null if the versions do not match at all . |
28,303 | public UrlStringBuilder setParameter ( String name , String ... values ) { this . setParameter ( name , values != null ? Arrays . asList ( values ) : null ) ; return this ; } | Sets a URL parameter replacing any existing parameter with the same name . |
28,304 | public UrlStringBuilder addParameter ( String name , String ... values ) { this . addParameter ( name , values != null ? Arrays . asList ( values ) : null ) ; return this ; } | Adds to a URL parameter if a parameter with the same name already exists its values are added to |
28,305 | public UrlStringBuilder setParameters ( String namespace , Map < String , List < String > > parameters ) { for ( final String name : parameters . keySet ( ) ) { Validate . notNull ( name , "parameter map cannot contain any null keys" ) ; } this . parameters . clear ( ) ; this . addParameters ( namespace , parameters ) ... | Removes all existing parameters and sets the contents of the specified Map as the parameters . |
28,306 | public UrlStringBuilder setPath ( String ... elements ) { Validate . noNullElements ( elements , "elements cannot be null" ) ; this . path . clear ( ) ; this . addPath ( elements ) ; return this ; } | Removes any existing path elements and sets the provided elements as the path |
28,307 | public UrlStringBuilder addPath ( String element ) { Validate . notNull ( element , "element cannot be null" ) ; this . path . add ( element ) ; return this ; } | Adds a single element to the path . |
28,308 | public UrlStringBuilder addPath ( String ... elements ) { Validate . noNullElements ( elements , "elements cannot be null" ) ; for ( final String element : elements ) { this . path . add ( element ) ; } return this ; } | Adds the provided elements to the path |
28,309 | @ SuppressWarnings ( "unchecked" ) protected Map < String , IPortletPreference > getSessionPreferences ( IPortletEntityId portletEntityId , HttpServletRequest httpServletRequest ) { final HttpSession session = httpServletRequest . getSession ( ) ; final Map < IPortletEntityId , Map < String , IPortletPreference > > por... | Gets the session - stored list of IPortletPreferences for the specified request and IPortletEntityId . |
28,310 | protected List < IPersonAttributes > searchDirectory ( String query , PortletRequest request ) { final Map < String , Object > queryAttributes = new HashMap < > ( ) ; for ( String attr : directoryQueryAttributes ) { queryAttributes . put ( attr , query ) ; } final List < IPersonAttributes > people ; HttpServletRequest ... | Search the directory for people matching the search query . Search results will be scoped to the permissions of the user performing the search . |
28,311 | protected boolean isMobile ( PortletRequest request ) { final String themeName = request . getProperty ( IPortletRenderer . THEME_NAME_PROPERTY ) ; return "UniversalityMobile" . equals ( themeName ) ; } | Determine if this should be a mobile view . |
28,312 | protected IPortletEntity unwrapEntity ( IPortletEntity portletEntity ) { if ( portletEntity instanceof TransientPortletEntity ) { return ( ( TransientPortletEntity ) portletEntity ) . getDelegatePortletEntity ( ) ; } return portletEntity ; } | Returns the unwrapped entity if it is an instance of TransientPortletEntity . If not the original entity is returned . |
28,313 | protected IPortletEntity wrapEntity ( IPortletEntity portletEntity ) { if ( portletEntity == null ) { return null ; } final String persistentLayoutNodeId = portletEntity . getLayoutNodeId ( ) ; if ( persistentLayoutNodeId . startsWith ( TransientUserLayoutManagerWrapper . SUBSCRIBE_PREFIX ) ) { final IUserLayoutManager... | Adds a TransientPortletEntity wrapper to the portletEntity if it is needed . If the specified entity is transient but no transient subscribe id has been registered for it yet in the transientIdMap null is returned . If no wrapping is needed the original entity is returned . |
28,314 | public static boolean isValidUrl ( String url ) { HttpURLConnection huc = null ; boolean isValid = false ; try { URL u = new URL ( url ) ; huc = ( HttpURLConnection ) u . openConnection ( ) ; huc . setRequestMethod ( "GET" ) ; huc . connect ( ) ; int response = huc . getResponseCode ( ) ; if ( response != HttpURLConnec... | Tests if a string is a valid URL Will open a connection and make sure that it can connect to the URL it looks for an HTTP status code of 200 on a GET . This is a valid URL . |
28,315 | public static < T > boolean included ( T value , Collection < ? extends T > includes , Collection < ? extends T > excludes ) { return ( includes . isEmpty ( ) && excludes . isEmpty ( ) ) || includes . contains ( value ) || ( includes . isEmpty ( ) && ! excludes . contains ( value ) ) ; } | Determines if the specified value is included based on the contents of the include and exclude collections . |
28,316 | public void init ( ContextRefreshedEvent event ) { idTokenFactory = context . getBean ( IdTokenFactory . class ) ; if ( guestUsernameSelectors == null ) { guestUsernameSelectors = Collections . emptyList ( ) ; } Collections . sort ( guestUsernameSelectors ) ; } | To avoid circular reference issues this bean obtains its dependencies when the context finishes starting . |
28,317 | protected boolean handleResourceHeader ( String key , String value ) { if ( ResourceResponse . HTTP_STATUS_CODE . equals ( key ) ) { this . portletResourceOutputHandler . setStatus ( Integer . parseInt ( value ) ) ; return true ; } if ( "Content-Type" . equals ( key ) ) { final ContentType contentType = ContentType . p... | Handles resource response specific headers . Returns true if the header was consumed by this method and requires no further processing |
28,318 | public void perform ( ) throws PortalException { if ( nodeId . startsWith ( Constants . FRAGMENT_ID_USER_PREFIX ) ) { ParameterEditManager . removeParmEditDirective ( nodeId , name , person ) ; } LPAChangeParameter . changeParameterChild ( ilfNode , name , fragmentValue ) ; } | Reset the parameter to not override the value specified by a fragment . This is done by removing the parm edit in the PLF and setting the value in the ILF to the passed - in fragment value . |
28,319 | public void add ( IPermission perm ) throws AuthorizationException { Connection conn = null ; int rc = 0 ; try { conn = RDBMServices . getConnection ( ) ; String sQuery = getInsertPermissionSql ( ) ; PreparedStatement ps = conn . prepareStatement ( sQuery ) ; try { primAdd ( perm , ps ) ; if ( log . isDebugEnabled ( ) ... | Add the IPermission to the store . |
28,320 | public void delete ( IPermission [ ] perms ) throws AuthorizationException { if ( perms . length > 0 ) { try { primDelete ( perms ) ; } catch ( Exception ex ) { log . error ( "Exception deleting permissions " + Arrays . toString ( perms ) , ex ) ; throw new AuthorizationException ( "Exception deleting permissions " + A... | Delete the IPermissions from the store . |
28,321 | public void delete ( IPermission perm ) throws AuthorizationException { Connection conn = null ; try { conn = RDBMServices . getConnection ( ) ; String sQuery = getDeletePermissionSql ( ) ; PreparedStatement ps = conn . prepareStatement ( sQuery ) ; try { primDelete ( perm , ps ) ; } finally { ps . close ( ) ; } } catc... | Delete a single IPermission from the store . |
28,322 | private int getPrincipalType ( String principalString ) { return Integer . parseInt ( principalString . substring ( 0 , principalString . indexOf ( PRINCIPAL_SEPARATOR ) ) ) ; } | Returns the principal type portion of the principal . |
28,323 | private int primDelete ( IPermission perm , PreparedStatement ps ) throws Exception { ps . clearParameters ( ) ; ps . setString ( 1 , perm . getOwner ( ) ) ; ps . setInt ( 2 , getPrincipalType ( perm ) ) ; ps . setString ( 3 , getPrincipalKey ( perm ) ) ; ps . setString ( 4 , perm . getActivity ( ) ) ; ps . setString (... | Set the params on the PreparedStatement and execute the delete . |
28,324 | private int primUpdate ( IPermission perm , PreparedStatement ps ) throws Exception { java . sql . Timestamp ts = null ; ps . clearParameters ( ) ; if ( perm . getType ( ) == null ) { ps . setNull ( 1 , Types . VARCHAR ) ; } else { ps . setString ( 1 , perm . getType ( ) ) ; } if ( perm . getEffective ( ) == null ) { p... | Set the params on the PreparedStatement and execute the update . |
28,325 | public IPermission [ ] select ( String owner , String principal , String activity , String target , String type ) throws AuthorizationException { Connection conn = null ; PreparedStatement stmt = null ; ResultSet rs = null ; List < IPermission > perms = new ArrayList < IPermission > ( ) ; String query = getSelectQuery ... | Select the Permissions from the store . |
28,326 | public void update ( IPermission perm ) throws AuthorizationException { Connection conn = null ; try { conn = RDBMServices . getConnection ( ) ; String sQuery = getUpdatePermissionSql ( ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "RDBMPermissionImpl.update(): " + sQuery ) ; PreparedStatement ps = conn . prepareSt... | Update a single IPermission in the store . |
28,327 | public PortletEventQueue getPortletEventQueue ( HttpServletRequest request ) { request = this . portalRequestUtils . getOriginalPortalRequest ( request ) ; synchronized ( PortalWebUtils . getRequestAttributeMutex ( request ) ) { PortletEventQueue portletEventQueue = ( PortletEventQueue ) request . getAttribute ( PORTLE... | Returns a request scoped PortletEventQueue used to track events to process and events to dispatch |
28,328 | protected HttpServletRequest getServletRequestFromExternalContext ( ExternalContext externalContext ) { Object request = externalContext . getNativeRequest ( ) ; if ( request instanceof PortletRequest ) { return portalRequestUtils . getPortletHttpRequest ( ( PortletRequest ) externalContext . getNativeRequest ( ) ) ; }... | Get the HttpServletRequest associated with the supplied ExternalContext . |
28,329 | protected IPortletDefinition getChannelDefinition ( String subId ) throws PortalException { IPortletDefinition chanDef = mChanMap . get ( subId ) ; if ( null == chanDef ) { String fname = getFname ( subId ) ; if ( log . isDebugEnabled ( ) ) log . debug ( "TransientUserLayoutManagerWrapper>>getChannelDefinition, " + "at... | Given a subscribe Id return a ChannelDefinition . |
28,330 | public String getSubscribeId ( String fname ) throws PortalException { String subId = mFnameMap . get ( fname ) ; if ( subId == null ) { subId = man . getSubscribeId ( fname ) ; } if ( subId == null ) { try { IPortletDefinition chanDef = PortletDefinitionRegistryLocator . getPortletDefinitionRegistry ( ) . getPortletDe... | Given an functional name return its subscribe id . |
28,331 | private IUserLayoutChannelDescription getTransientNode ( String nodeId ) throws PortalException { final String fname = getFname ( nodeId ) ; if ( null == fname || fname . equals ( "" ) ) { return null ; } try { IPortletDefinition chanDef = mChanMap . get ( nodeId ) ; if ( null == chanDef ) { chanDef = PortletDefinition... | Return an IUserLayoutChannelDescription by way of nodeId |
28,332 | public boolean sendEvent ( LrsStatement statement ) { if ( ! isEnabled ( ) ) { return false ; } ResponseEntity < Object > response = sendRequest ( STATEMENTS_REST_ENDPOINT , HttpMethod . POST , null , statement , Object . class ) ; if ( response . getStatusCode ( ) . series ( ) == Series . SUCCESSFUL ) { logger . trace... | Actually send an event to the provider . |
28,333 | protected void loadConfig ( ) { if ( ! isEnabled ( ) ) { return ; } final String urlProp = format ( PROPERTY_FORMAT , id , "url" ) ; LRSUrl = propertyResolver . getProperty ( urlProp ) ; actorName = propertyResolver . getProperty ( format ( PROPERTY_FORMAT , id , "actor-name" ) , actorName ) ; actorEmail = propertyReso... | Read the LRS config . |
28,334 | protected < T > ResponseEntity < T > sendRequest ( String pathFragment , HttpMethod method , List < ? extends NameValuePair > getParams , Object postData , Class < T > returnType ) { HttpHeaders headers = new HttpHeaders ( ) ; headers . add ( XAPI_VERSION_HEADER , XAPI_VERSION_VALUE ) ; if ( postData instanceof MultiVa... | Send a request to the LRS . |
28,335 | private URI buildRequestURI ( String pathFragment , List < ? extends NameValuePair > params ) { try { String queryString = "" ; if ( params != null && ! params . isEmpty ( ) ) { queryString = "?" + URLEncodedUtils . format ( params , "UTF-8" ) ; } URI fullURI = new URI ( LRSUrl + pathFragment + queryString ) ; return f... | Build a URI for the REST request . |
28,336 | protected void bindAggregationSpecificKeyParameters ( TypedQuery < PortletExecutionAggregationImpl > query , Set < PortletExecutionAggregationKey > keys ) { query . setParameter ( this . portletMappingParameter , extractAggregatePortletMappings ( keys ) ) ; query . setParameter ( this . executionTypeParameter , extract... | The execution type is obtained from the first PortletExecutionAggregationKey . |
28,337 | protected EntityManager getTransactionalEntityManager ( EntityManagerFactory emf ) throws IllegalStateException { Assert . state ( emf != null , "No EntityManagerFactory specified" ) ; return EntityManagerFactoryUtils . getTransactionalEntityManager ( emf ) ; } | Obtain the transactional EntityManager for this accessor s EntityManagerFactory if any . |
28,338 | protected EntityManagerFactory getEntityManagerFactory ( OpenEntityManager openEntityManager ) { final CacheKey key = this . createEntityManagerFactoryKey ( openEntityManager ) ; EntityManagerFactory emf = this . entityManagerFactories . get ( key ) ; if ( emf == null ) { emf = this . lookupEntityManagerFactory ( openE... | Get the EntityManagerFactory that this filter should use . |
28,339 | protected EntityManagerFactory lookupEntityManagerFactory ( OpenEntityManager openEntityManager ) { String emfBeanName = openEntityManager . name ( ) ; String puName = openEntityManager . unitName ( ) ; if ( StringUtils . hasLength ( emfBeanName ) ) { return this . applicationContext . getBean ( emfBeanName , EntityMan... | Look up the EntityManagerFactory that this filter should use . |
28,340 | public synchronized Object put ( Object key , Object value ) { ValueWrapper valueWrapper = new ValueWrapper ( value ) ; return super . put ( key , valueWrapper ) ; } | Add a new value to the cache . The value will expire in accordance with the cache s expiration timeout value which was set when the cache was created . |
28,341 | public synchronized Object put ( Object key , Object value , long lCacheInterval ) { ValueWrapper valueWrapper = new ValueWrapper ( value , lCacheInterval ) ; return super . put ( key , valueWrapper ) ; } | Add a new value to the cache |
28,342 | public synchronized Object get ( Object key ) { ValueWrapper valueWrapper = ( ValueWrapper ) super . get ( key ) ; if ( valueWrapper != null ) { long creationTime = valueWrapper . getCreationTime ( ) ; long cacheInterval = valueWrapper . getCacheInterval ( ) ; long currentTime = System . currentTimeMillis ( ) ; if ( ca... | Get an object from the cache . |
28,343 | protected void sweepCache ( ) { for ( Iterator keyIterator = keySet ( ) . iterator ( ) ; keyIterator . hasNext ( ) ; ) { Object key = keyIterator . next ( ) ; ValueWrapper valueWrapper = ( ValueWrapper ) super . get ( key ) ; long creationTime = valueWrapper . getCreationTime ( ) ; long cacheInterval = valueWrapper . g... | Removes from the cache values which have expired . |
28,344 | private String getInitParameter ( String name , String defaultValue ) { String value = getInitParameter ( name ) ; if ( value != null ) { return value ; } return defaultValue ; } | This method returns the parameter s value if it exists or defaultValue if not . |
28,345 | private String getMediaType ( String contentType ) { if ( contentType == null ) { return null ; } String result = contentType . toLowerCase ( Locale . ENGLISH ) ; int firstSemiColonIndex = result . indexOf ( ';' ) ; if ( firstSemiColonIndex > - 1 ) { result = result . substring ( 0 , firstSemiColonIndex ) ; } result = ... | Return the lower case trimmed value of the media type from the content type . |
28,346 | public void endParsing ( ) throws SnowflakeSQLException { if ( partialEscapedUnicode . position ( ) > 0 ) { partialEscapedUnicode . flip ( ) ; continueParsingInternal ( partialEscapedUnicode , true ) ; partialEscapedUnicode . clear ( ) ; } if ( state != State . ROW_FINISHED ) { throw new SnowflakeSQLException ( SqlStat... | Check if the chunk has been parsed correctly . After calling this it is safe to acquire the output data |
28,347 | public void continueParsing ( ByteBuffer in ) throws SnowflakeSQLException { if ( state == State . UNINITIALIZED ) { throw new SnowflakeSQLException ( SqlState . INTERNAL_ERROR , ErrorCode . INTERNAL_ERROR . getMessageCode ( ) , "Json parser hasn't been initialized!" ) ; } if ( partialEscapedUnicode . position ( ) > 0 ... | Continue parsing with the given data |
28,348 | public static void cancel ( StmtInput stmtInput ) throws SFException , SnowflakeSQLException { HttpPost httpRequest = null ; AssertUtil . assertTrue ( stmtInput . serverUrl != null , "Missing server url for statement execution" ) ; AssertUtil . assertTrue ( stmtInput . sql != null , "Missing sql for statement execution... | Cancel a statement identifiable by a request id |
28,349 | static public SFStatementType checkStageManageCommand ( String sql ) { if ( sql == null ) { return null ; } String trimmedSql = sql . trim ( ) ; while ( trimmedSql . startsWith ( "//" ) ) { logger . debug ( "skipping // comments in: \n{}" , trimmedSql ) ; if ( trimmedSql . indexOf ( '\n' ) > 0 ) { trimmedSql = trimmedS... | A simple function to check if the statement is related to manipulate stage . |
28,350 | public void flush ( ) { if ( ! enabled ) { return ; } if ( ! queue . isEmpty ( ) ) { Runnable runUpload = new TelemetryUploader ( this , exportQueueToString ( ) ) ; uploader . execute ( runUpload ) ; } } | force to flush events in the queue |
28,351 | public String exportQueueToString ( ) { JSONArray logs = new JSONArray ( ) ; while ( ! queue . isEmpty ( ) ) { logs . add ( queue . poll ( ) ) ; } return SecretDetector . maskAWSSecret ( logs . toString ( ) ) ; } | convert a list of json objects to a string |
28,352 | public void logHttpRequestTelemetryEvent ( String eventName , HttpRequestBase request , int injectSocketTimeout , AtomicBoolean canceling , boolean withoutCookies , boolean includeRetryParameters , boolean includeRequestGuid , CloseableHttpResponse response , final Exception savedEx , String breakRetryReason , long ret... | log error http response to telemetry |
28,353 | public final Object getCell ( int rowIdx , int colIdx ) { if ( resultData != null ) { return extractCell ( resultData , rowIdx , colIdx ) ; } return data . get ( colCount * rowIdx + colIdx ) ; } | Creates a String object for the given cell |
28,354 | public final void ensureRowsComplete ( ) throws SnowflakeSQLException { if ( rowCount != currentRow ) { throw new SnowflakeSQLException ( SqlState . INTERNAL_ERROR , ErrorCode . INTERNAL_ERROR . getMessageCode ( ) , "Exception: expected " + rowCount + " rows and received " + currentRow ) ; } } | Checks that all data has been added after parsing . |
28,355 | static CloseableHttpClient buildHttpClient ( boolean insecureMode , File ocspCacheFile , boolean useOcspCacheServer ) { DefaultRequestConfig = RequestConfig . custom ( ) . setConnectTimeout ( DEFAULT_CONNECTION_TIMEOUT ) . setConnectionRequestTimeout ( DEFAULT_CONNECTION_TIMEOUT ) . setSocketTimeout ( DEFAULT_HTTP_CLIE... | Build an Http client using our set of default . |
28,356 | public static CloseableHttpClient initHttpClient ( boolean insecureMode , File ocspCacheFile ) { if ( httpClient == null ) { synchronized ( HttpUtil . class ) { if ( httpClient == null ) { httpClient = buildHttpClient ( insecureMode , ocspCacheFile , enableOcspResponseCacheServer ( ) ) ; } } } return httpClient ; } | Accessor for the HTTP client singleton . |
28,357 | public static RequestConfig getDefaultRequestConfigWithSocketTimeout ( int soTimeoutMs , boolean withoutCookies ) { getHttpClient ( ) ; final String cookieSpec = withoutCookies ? IGNORE_COOKIES : DEFAULT ; return RequestConfig . copy ( DefaultRequestConfig ) . setSocketTimeout ( soTimeoutMs ) . setCookieSpec ( cookieSp... | Return a request configuration inheriting from the default request configuration of the shared HttpClient with a different socket timeout . |
28,358 | static String executeRequestWithoutCookies ( HttpRequestBase httpRequest , int retryTimeout , int injectSocketTimeout , AtomicBoolean canceling ) throws SnowflakeSQLException , IOException { return executeRequestInternal ( httpRequest , retryTimeout , injectSocketTimeout , canceling , true , false , true ) ; } | Executes a HTTP request with the cookie spec set to IGNORE_COOKIES |
28,359 | public static String executeRequest ( HttpRequestBase httpRequest , int retryTimeout , int injectSocketTimeout , AtomicBoolean canceling ) throws SnowflakeSQLException , IOException { return executeRequest ( httpRequest , retryTimeout , injectSocketTimeout , canceling , false ) ; } | Executes a HTTP request for Snowflake . |
28,360 | public static void configureCustomProxyProperties ( Map < SFSessionProperty , Object > connectionPropertiesMap ) { if ( connectionPropertiesMap . containsKey ( SFSessionProperty . USE_PROXY ) ) { useProxy = ( boolean ) connectionPropertiesMap . get ( SFSessionProperty . USE_PROXY ) ; } if ( useProxy ) { proxyHost = ( S... | configure custom proxy properties from connectionPropertiesMap |
28,361 | static private void checkErrorAndThrowExceptionSub ( JsonNode rootNode , boolean raiseReauthenticateError ) throws SnowflakeSQLException { if ( rootNode . path ( "success" ) . asBoolean ( ) ) { return ; } String errorMessage ; String sqlState ; int errorCode ; String queryId = "unknown" ; if ( ! rootNode . path ( "data... | Check the error in the JSON node and generate an exception based on information extracted from the node . |
28,362 | static void assertTrue ( boolean condition , String internalErrorMesg ) throws SFException { if ( ! condition ) { throw new SFException ( ErrorCode . INTERNAL_ERROR , internalErrorMesg ) ; } } | Assert the condition is true otherwise throw an internal error exception with the given message . |
28,363 | public static MatDesc parse ( String matdesc ) { if ( matdesc == null ) { return null ; } try { JsonNode jsonNode = mapper . readTree ( matdesc ) ; JsonNode queryIdNode = jsonNode . path ( QUERY_ID ) ; if ( queryIdNode . isMissingNode ( ) || queryIdNode . isNull ( ) ) { return null ; } JsonNode smkIdNode = jsonNode . p... | Try to parse the material descriptor string . |
28,364 | private SFPair < String , String > applySessionContext ( String catalog , String schemaPattern ) { if ( catalog == null && metadataRequestUseConnectionCtx ) { catalog = session . getDatabase ( ) ; if ( schemaPattern == null ) { schemaPattern = session . getSchema ( ) ; } } return SFPair . of ( catalog , schemaPattern )... | apply session context when catalog is unspecified |
28,365 | private short getForeignKeyConstraintProperty ( String property_name , String property ) { short result = 0 ; switch ( property_name ) { case "update" : case "delete" : switch ( property ) { case "NO ACTION" : result = importedKeyNoAction ; break ; case "CASCADE" : result = importedKeyCascade ; break ; case "SET NULL" ... | Returns the JDBC standard property string for the property string used in our show constraint commands |
28,366 | private ResultSet executeAndReturnEmptyResultIfNotFound ( Statement statement , String sql , DBMetadataResultSetMetadata metadataType ) throws SQLException { ResultSet resultSet ; try { resultSet = statement . executeQuery ( sql ) ; } catch ( SnowflakeSQLException e ) { if ( e . getSQLState ( ) . equals ( SqlState . NO... | A small helper function to execute show command to get metadata And if object does not exist return an empty result set instead of throwing a SnowflakeSQLException |
28,367 | static private ClientAuthnDTO . AuthenticatorType getAuthenticator ( LoginInput loginInput ) { if ( loginInput . getAuthenticator ( ) != null ) { if ( loginInput . getAuthenticator ( ) . equalsIgnoreCase ( ClientAuthnDTO . AuthenticatorType . EXTERNALBROWSER . name ( ) ) ) { return ClientAuthnDTO . AuthenticatorType . ... | Returns Authenticator type |
28,368 | static public LoginOutput openSession ( LoginInput loginInput ) throws SFException , SnowflakeSQLException { AssertUtil . assertTrue ( loginInput . getServerUrl ( ) != null , "missing server URL for opening session" ) ; AssertUtil . assertTrue ( loginInput . getAppId ( ) != null , "missing app id for opening session" )... | Open a new session |
28,369 | static public LoginOutput issueSession ( LoginInput loginInput ) throws SFException , SnowflakeSQLException { return tokenRequest ( loginInput , TokenRequestType . ISSUE ) ; } | Issue a session |
28,370 | static public void closeSession ( LoginInput loginInput ) throws SFException , SnowflakeSQLException { logger . debug ( " public void close() throws SFException" ) ; AssertUtil . assertTrue ( loginInput . getServerUrl ( ) != null , "missing server URL for closing session" ) ; AssertUtil . assertTrue ( loginInput . getS... | Close a session |
28,371 | private static String federatedFlowStep3 ( LoginInput loginInput , String tokenUrl ) throws SnowflakeSQLException { String oneTimeToken = "" ; try { URL url = new URL ( tokenUrl ) ; URI tokenUri = url . toURI ( ) ; final HttpPost postRequest = new HttpPost ( tokenUri ) ; StringEntity params = new StringEntity ( "{\"use... | Query IDP token url to authenticate and retrieve access token |
28,372 | private static JsonNode federatedFlowStep1 ( LoginInput loginInput ) throws SnowflakeSQLException { JsonNode dataNode = null ; try { URIBuilder fedUriBuilder = new URIBuilder ( loginInput . getServerUrl ( ) ) ; fedUriBuilder . setPath ( SF_PATH_AUTHENTICATOR_REQUEST ) ; URI fedUrlUri = fedUriBuilder . build ( ) ; Map <... | Query Snowflake to obtain IDP token url and IDP SSO url |
28,373 | private static void handleFederatedFlowError ( LoginInput loginInput , Exception ex ) throws SnowflakeSQLException { if ( ex instanceof IOException ) { logger . error ( "IOException when authenticating with " + loginInput . getAuthenticator ( ) , ex ) ; throw new SnowflakeSQLException ( ex , SqlState . IO_ERROR , Error... | Logs an error generated during the federated authentication flow and re - throws it as a SnowflakeSQLException . Note that we seperate IOExceptions since those tend to be network related . |
28,374 | static private String getSamlResponseUsingOkta ( LoginInput loginInput ) throws SnowflakeSQLException { JsonNode dataNode = federatedFlowStep1 ( loginInput ) ; String tokenUrl = dataNode . path ( "tokenUrl" ) . asText ( ) ; String ssoUrl = dataNode . path ( "ssoUrl" ) . asText ( ) ; federatedFlowStep2 ( loginInput , to... | FEDERATED FLOW See SNOW - 27798 for additional details . |
28,375 | static boolean isPrefixEqual ( String aUrlStr , String bUrlStr ) throws MalformedURLException { URL aUrl = new URL ( aUrlStr ) ; URL bUrl = new URL ( bUrlStr ) ; int aPort = aUrl . getPort ( ) ; int bPort = bUrl . getPort ( ) ; if ( aPort == - 1 && "https" . equals ( aUrl . getProtocol ( ) ) ) { aPort = 443 ; } if ( bP... | Verify if two input urls have the same protocol host and port . |
28,376 | static private String getPostBackUrlFromHTML ( String html ) { Document doc = Jsoup . parse ( html ) ; Elements e1 = doc . getElementsByTag ( "body" ) ; Elements e2 = e1 . get ( 0 ) . getElementsByTag ( "form" ) ; String postBackUrl = e2 . first ( ) . attr ( "action" ) ; return postBackUrl ; } | Extracts post back url from the HTML returned by the IDP |
28,377 | public static Map < String , Object > getCommonParams ( JsonNode paramsNode ) { Map < String , Object > parameters = new HashMap < > ( ) ; for ( JsonNode child : paramsNode ) { if ( ! child . hasNonNull ( "name" ) ) { logger . error ( "Common Parameter JsonNode encountered with " + "no parameter name!" ) ; continue ; }... | Helper function to parse a JsonNode from a GS response containing CommonParameters emitting an EnumMap of parameters |
28,378 | protected ServerSocket getServerSocket ( ) throws SFException { try { return new ServerSocket ( 0 , 0 , InetAddress . getByName ( "localhost" ) ) ; } catch ( IOException ex ) { throw new SFException ( ex , ErrorCode . NETWORK_ERROR , ex . getMessage ( ) ) ; } } | Gets a free port on localhost |
28,379 | private String getSSOUrl ( int port ) throws SFException , SnowflakeSQLException { try { String serverUrl = loginInput . getServerUrl ( ) ; String authenticator = loginInput . getAuthenticator ( ) ; URIBuilder fedUriBuilder = new URIBuilder ( serverUrl ) ; fedUriBuilder . setPath ( SessionUtil . SF_PATH_AUTHENTICATOR_R... | Gets SSO URL and proof key |
28,380 | private void processSamlToken ( String [ ] rets , Socket socket ) throws IOException , SFException { String targetLine = null ; String userAgent = null ; boolean isPost = false ; for ( String line : rets ) { if ( line . length ( ) > PREFIX_GET . length ( ) && line . substring ( 0 , PREFIX_GET . length ( ) ) . equalsIgn... | Receives SAML token from Snowflake via web browser |
28,381 | private void returnToBrowser ( Socket socket ) throws IOException { PrintWriter out = new PrintWriter ( socket . getOutputStream ( ) , true ) ; List < String > content = new ArrayList < > ( ) ; content . add ( "HTTP/1.0 200 OK" ) ; content . add ( "Content-Type: text/html" ) ; String responseText ; if ( this . origin !... | Output the message to the browser |
28,382 | public static TelemetryData buildJobData ( String queryId , TelemetryField field , long value ) { ObjectNode obj = mapper . createObjectNode ( ) ; obj . put ( TYPE , field . toString ( ) ) ; obj . put ( QUERY_ID , queryId ) ; obj . put ( VALUE , value ) ; return new TelemetryData ( obj , System . currentTimeMillis ( ) ... | Create a simple TelemetryData instance for Job metrics using given parameters |
28,383 | public void download ( SFSession connection , String command , String localLocation , String destFileName , int parallelism , String remoteStorageLocation , String stageFilePath , String stageRegion ) throws SnowflakeSQLException { TransferManager tx = null ; int retryCount = 0 ; do { try { File localFile = new File ( ... | Download a file from S3 . |
28,384 | static void resetOCSPResponseCacherServerURL ( String ocspCacheServerUrl ) { if ( ocspCacheServerUrl == null || SF_OCSP_RESPONSE_CACHE_SERVER_RETRY_URL_PATTERN != null ) { return ; } SF_OCSP_RESPONSE_CACHE_SERVER_URL = ocspCacheServerUrl ; if ( ! SF_OCSP_RESPONSE_CACHE_SERVER_URL . startsWith ( DEFAULT_OCSP_CACHE_HOST ... | Reset OCSP Cache server URL |
28,385 | private X509TrustManager getTrustManager ( String algorithm ) { try { TrustManagerFactory factory = TrustManagerFactory . getInstance ( algorithm ) ; factory . init ( ( KeyStore ) null ) ; X509TrustManager ret = null ; for ( TrustManager tm : factory . getTrustManagers ( ) ) { if ( tm instanceof X509TrustManager ) { re... | Get TrustManager for the algorithm . This is mainly used to get the JVM default trust manager and cache all of the root CA . |
28,386 | void validateRevocationStatus ( X509Certificate [ ] chain , String peerHost ) throws CertificateException { final List < Certificate > bcChain = convertToBouncyCastleCertificate ( chain ) ; final List < SFPair < Certificate , Certificate > > pairIssuerSubjectList = getPairIssuerSubject ( bcChain ) ; if ( peerHost . sta... | Certificate Revocation checks |
28,387 | private void executeRevocationStatusChecks ( List < SFPair < Certificate , Certificate > > pairIssuerSubjectList , String peerHost ) throws CertificateException { long currentTimeSecond = new Date ( ) . getTime ( ) / 1000L ; try { for ( SFPair < Certificate , Certificate > pairIssuerSubject : pairIssuerSubjectList ) { ... | Executes the revocation status checks for all chained certificates |
28,388 | private static String encodeCacheKey ( OcspResponseCacheKey ocsp_cache_key ) { try { DigestCalculator digest = new SHA1DigestCalculator ( ) ; AlgorithmIdentifier algo = digest . getAlgorithmIdentifier ( ) ; ASN1OctetString nameHash = ASN1OctetString . getInstance ( ocsp_cache_key . nameHash ) ; ASN1OctetString keyHash ... | Convert cache key to base64 encoded cert id |
28,389 | private boolean isCached ( List < SFPair < Certificate , Certificate > > pairIssuerSubjectList ) { long currentTimeSecond = new Date ( ) . getTime ( ) / 1000L ; boolean isCached = true ; try { for ( SFPair < Certificate , Certificate > pairIssuerSubject : pairIssuerSubjectList ) { OCSPReq req = createRequest ( pairIssu... | Is OCSP Response cached? |
28,390 | private static String CertificateIDToString ( CertificateID certificateID ) { return String . format ( "CertID. NameHash: %s, KeyHash: %s, Serial Number: %s" , byteToHexString ( certificateID . getIssuerNameHash ( ) ) , byteToHexString ( certificateID . getIssuerKeyHash ( ) ) , MessageFormat . format ( "{0,number,#}" ,... | CertificateID to string |
28,391 | private static SFPair < OcspResponseCacheKey , SFPair < Long , String > > decodeCacheFromJSON ( Map . Entry < String , JsonNode > elem ) throws IOException { long currentTimeSecond = new Date ( ) . getTime ( ) / 1000 ; byte [ ] certIdDer = Base64 . decodeBase64 ( elem . getKey ( ) ) ; DLSequence rawCertId = ( DLSequenc... | Decodes OCSP Response Cache key from JSON |
28,392 | private static ObjectNode encodeCacheToJSON ( ) { try { ObjectNode out = OBJECT_MAPPER . createObjectNode ( ) ; for ( Map . Entry < OcspResponseCacheKey , SFPair < Long , String > > elem : OCSP_RESPONSE_CACHE . entrySet ( ) ) { OcspResponseCacheKey key = elem . getKey ( ) ; SFPair < Long , String > value0 = elem . getV... | Encode OCSP Response Cache to JSON |
28,393 | private void validateRevocationStatusMain ( SFPair < Certificate , Certificate > pairIssuerSubject , String ocspRespB64 ) throws CertificateException { try { OCSPResp ocspResp = b64ToOCSPResp ( ocspRespB64 ) ; Date currentTime = new Date ( ) ; BasicOCSPResp basicOcspResp = ( BasicOCSPResp ) ( ocspResp . getResponseObje... | Validates the certificate revocation status |
28,394 | private void validateBasicOcspResponse ( Date currentTime , BasicOCSPResp basicOcspResp ) throws CertificateEncodingException { for ( SingleResp singleResps : basicOcspResp . getResponses ( ) ) { Date thisUpdate = singleResps . getThisUpdate ( ) ; Date nextUpdate = singleResps . getNextUpdate ( ) ; LOGGER . debug ( "Cu... | Validates OCSP Basic OCSP response . |
28,395 | private static void verifySignature ( X509CertificateHolder cert , byte [ ] sig , byte [ ] data , AlgorithmIdentifier idf ) throws CertificateException { try { String algorithm = SIGNATURE_OID_TO_STRING . get ( idf . getAlgorithm ( ) ) ; if ( algorithm == null ) { throw new NoSuchAlgorithmException ( String . format ( ... | Verifies the signature of the data |
28,396 | private static String byteToHexString ( byte [ ] bytes ) { final char [ ] hexArray = "0123456789ABCDEF" . toCharArray ( ) ; char [ ] hexChars = new char [ bytes . length * 2 ] ; for ( int j = 0 ; j < bytes . length ; j ++ ) { int v = bytes [ j ] & 0xFF ; hexChars [ j * 2 ] = hexArray [ v >>> 4 ] ; hexChars [ j * 2 + 1 ... | Converts Byte array to hex string |
28,397 | private OCSPReq createRequest ( SFPair < Certificate , Certificate > pairIssuerSubject ) { Certificate issuer = pairIssuerSubject . left ; Certificate subject = pairIssuerSubject . right ; OCSPReqBuilder gen = new OCSPReqBuilder ( ) ; try { DigestCalculator digest = new SHA1DigestCalculator ( ) ; X509CertificateHolder ... | Creates a OCSP Request |
28,398 | private List < Certificate > convertToBouncyCastleCertificate ( X509Certificate [ ] chain ) { final List < Certificate > bcChain = new ArrayList < > ( ) ; for ( X509Certificate cert : chain ) { try { bcChain . add ( Certificate . getInstance ( cert . getEncoded ( ) ) ) ; } catch ( CertificateEncodingException ex ) { th... | Converts X509Certificate to Bouncy Castle Certificate |
28,399 | private List < SFPair < Certificate , Certificate > > getPairIssuerSubject ( List < Certificate > bcChain ) { List < SFPair < Certificate , Certificate > > pairIssuerSubject = new ArrayList < > ( ) ; for ( int i = 0 , len = bcChain . size ( ) ; i < len ; ++ i ) { Certificate bcCert = bcChain . get ( i ) ; if ( bcCert .... | Creates a pair of Issuer and Subject certificates |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.