idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
35,700
private PBXObjectRef addDocumentationGroup ( final Map objects , final String sourceTree ) { final List productsList = new ArrayList ( ) ; final PBXObjectRef products = createPBXGroup ( "Documentation" , sourceTree , productsList ) ; objects . put ( products . getID ( ) , products . getProperties ( ) ) ; return products ; }
Add documentation group to map of objects .
35,701
private PBXObjectRef addNativeTarget ( final Map objects , final TargetInfo linkTarget , final PBXObjectRef product , final String projectName , final List < PBXObjectRef > sourceGroupChildren , final List < PBXObjectRef > frameworkBuildFiles ) { final PBXObjectRef buildConfigurations = addNativeTargetConfigurationList ( objects , projectName ) ; int buildActionMask = 2147483647 ; final List < PBXObjectRef > buildPhases = new ArrayList < > ( ) ; final Map settings = new HashMap ( ) ; settings . put ( "ATTRIBUTES" , new ArrayList ( ) ) ; final List buildFiles = new ArrayList ( ) ; for ( final PBXObjectRef sourceFile : sourceGroupChildren ) { final PBXObjectRef buildFile = createPBXBuildFile ( sourceFile , settings ) ; buildFiles . add ( buildFile ) ; objects . put ( buildFile . getID ( ) , buildFile . getProperties ( ) ) ; } final PBXObjectRef sourcesBuildPhase = createPBXSourcesBuildPhase ( buildActionMask , buildFiles , false ) ; objects . put ( sourcesBuildPhase . getID ( ) , sourcesBuildPhase . getProperties ( ) ) ; buildPhases . add ( sourcesBuildPhase ) ; buildActionMask = 8 ; final PBXObjectRef frameworksBuildPhase = createPBXFrameworksBuildPhase ( buildActionMask , frameworkBuildFiles , false ) ; objects . put ( frameworksBuildPhase . getID ( ) , frameworksBuildPhase . getProperties ( ) ) ; buildPhases . add ( frameworksBuildPhase ) ; final PBXObjectRef copyFilesBuildPhase = createPBXCopyFilesBuildPhase ( 8 , "/usr/share/man/man1" , "0" , new ArrayList ( ) , true ) ; objects . put ( copyFilesBuildPhase . getID ( ) , copyFilesBuildPhase . getProperties ( ) ) ; buildPhases . add ( copyFilesBuildPhase ) ; final List buildRules = new ArrayList ( ) ; final List dependencies = new ArrayList ( ) ; final String productInstallPath = "$(HOME)/bin" ; final String productType = getProductType ( linkTarget ) ; final PBXObjectRef nativeTarget = createPBXNativeTarget ( projectName , buildConfigurations , buildPhases , buildRules , dependencies , productInstallPath , projectName , product , productType ) ; objects . put ( nativeTarget . getID ( ) , nativeTarget . getProperties ( ) ) ; return nativeTarget ; }
Add native target to map of objects .
35,702
private PBXObjectRef addNativeTargetConfigurationList ( final Map objects , final String projectName ) { final List < PBXObjectRef > configurations = new ArrayList < > ( ) ; final Map debugSettings = new HashMap ( ) ; debugSettings . put ( "COPY_PHASE_STRIP" , "NO" ) ; debugSettings . put ( "GCC_DYNAMIC_NO_PIC" , "NO" ) ; debugSettings . put ( "GCC_ENABLE_FIX_AND_CONTINUE" , "YES" ) ; debugSettings . put ( "GCC_MODEL_TUNING" , "G5" ) ; debugSettings . put ( "GCC_OPTIMIZATION_LEVEL" , "0" ) ; debugSettings . put ( "INSTALL_PATH" , "$(HOME)/bin" ) ; debugSettings . put ( "PRODUCT_NAME" , projectName ) ; debugSettings . put ( "ZERO_LINK" , "YES" ) ; final PBXObjectRef debugConfig = createXCBuildConfiguration ( "Debug" , debugSettings ) ; objects . put ( debugConfig . getID ( ) , debugConfig . getProperties ( ) ) ; configurations . add ( debugConfig ) ; final Map < String , Object > releaseSettings = new HashMap < > ( ) ; final List < String > archs = new ArrayList < > ( ) ; archs . add ( "ppc" ) ; archs . add ( "i386" ) ; releaseSettings . put ( "ARCHS" , archs ) ; releaseSettings . put ( "GCC_GENERATE_DEBUGGING_SYMBOLS" , "NO" ) ; releaseSettings . put ( "GCC_MODEL_TUNING" , "G5" ) ; releaseSettings . put ( "INSTALL_PATH" , "$(HOME)/bin" ) ; releaseSettings . put ( "PRODUCT_NAME" , projectName ) ; final PBXObjectRef releaseConfig = createXCBuildConfiguration ( "Release" , releaseSettings ) ; objects . put ( releaseConfig . getID ( ) , releaseConfig . getProperties ( ) ) ; configurations . add ( releaseConfig ) ; final PBXObjectRef configurationList = createXCConfigurationList ( configurations ) ; objects . put ( configurationList . getID ( ) , configurationList . getProperties ( ) ) ; return configurationList ; }
Add native target configuration list .
35,703
private PBXObjectRef addProduct ( final Map objects , final TargetInfo linkTarget ) { final PBXObjectRef executable = createPBXFileReference ( "BUILD_PRODUCTS_DIR" , linkTarget . getOutput ( ) . getParent ( ) , linkTarget . getOutput ( ) ) ; final Map executableProperties = executable . getProperties ( ) ; final String fileType = getFileType ( linkTarget ) ; executableProperties . put ( "explicitFileType" , fileType ) ; executableProperties . put ( "includeInIndex" , "0" ) ; objects . put ( executable . getID ( ) , executableProperties ) ; return executable ; }
Add file reference of product to map of objects .
35,704
private List < PBXObjectRef > addSources ( final Map objects , final String sourceTree , final String basePath , final Map < String , TargetInfo > targets ) { final List < PBXObjectRef > sourceGroupChildren = new ArrayList < > ( ) ; final List < File > sourceList = new ArrayList < > ( targets . size ( ) ) ; for ( final TargetInfo info : targets . values ( ) ) { final File [ ] targetsources = info . getSources ( ) ; Collections . addAll ( sourceList , targetsources ) ; } final File [ ] sortedSources = sourceList . toArray ( new File [ sourceList . size ( ) ] ) ; Arrays . sort ( sortedSources , new Comparator < File > ( ) { public int compare ( final File o1 , final File o2 ) { return o1 . getName ( ) . compareTo ( o2 . getName ( ) ) ; } } ) ; for ( final File sortedSource : sortedSources ) { final PBXObjectRef fileRef = createPBXFileReference ( sourceTree , basePath , sortedSource ) ; sourceGroupChildren . add ( fileRef ) ; objects . put ( fileRef . getID ( ) , fileRef . getProperties ( ) ) ; } return sourceGroupChildren ; }
Add file references for all source files to map of objects .
35,705
protected void addIncludes ( final String baseDirPath , final File [ ] includeDirs , final Vector < String > args , final Vector < String > relativeArgs , final StringBuffer includePathId , final boolean isSystem ) { for ( final File includeDir : includeDirs ) { args . addElement ( getIncludeDirSwitch ( includeDir . getAbsolutePath ( ) , isSystem ) ) ; if ( relativeArgs != null ) { final String relative = CUtil . getRelativePath ( baseDirPath , includeDir ) ; relativeArgs . addElement ( getIncludeDirSwitch ( relative , isSystem ) ) ; if ( includePathId != null ) { if ( includePathId . length ( ) == 0 ) { includePathId . append ( "/I" ) ; } else { includePathId . append ( " /I" ) ; } includePathId . append ( relative ) ; } } } }
Adds command - line arguments for include directories .
35,706
protected int getTotalArgumentLengthForInputFile ( final File outputDir , final String inputFile ) { final int argumentCountPerInputFile = getArgumentCountPerInputFile ( ) ; int len = 0 ; for ( int k = 0 ; k < argumentCountPerInputFile ; k ++ ) { len += getInputFileArgument ( outputDir , inputFile , k ) . length ( ) ; } return len + argumentCountPerInputFile ; }
Get total command line length due to the input file .
35,707
public File getPrototype ( ) { final PrecompileDef ref = getRef ( ) ; if ( ref != null ) { return ref . getPrototype ( ) ; } return this . prototype ; }
Gets prototype source file
35,708
public void setPrototype ( final File prototype ) { if ( isReference ( ) ) { throw tooManyAttributes ( ) ; } if ( prototype == null ) { throw new NullPointerException ( "prototype" ) ; } this . prototype = prototype ; }
Sets file to precompile .
35,709
public boolean isSharedLibrary ( ) { final String value = this . outputType . getValue ( ) ; return value . equals ( "shared" ) || value . equals ( "plugin" ) || value . equals ( "jni" ) ; }
Gets whether the link should produce a shared library .
35,710
public void link ( final CCTask task , final File outputFile , final String [ ] sourceFiles , final CommandLineLinkerConfiguration config ) { outputFile . delete ( ) ; super . link ( task , outputFile , sourceFiles , config ) ; }
Builds a library .
35,711
private final < T > Object parseTypeArr ( Converter < T > converter , Class < T > valType , String [ ] arr ) throws Exception { Object objArr = Array . newInstance ( valType , arr . length ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { T item = converter . parseFromString ( valType , null , null , arr [ i ] ) ; Array . set ( objArr , i , item ) ; } return objArr ; }
say hello to arrays of primitives
35,712
private static String getName ( String name , Field field ) { if ( isEmpty ( name ) ) { name = field . getName ( ) ; } return name ; }
JSON & XML
35,713
public static SSLContext getInstance ( boolean server ) throws GeneralSecurityException { SSLContext retInstance = null ; if ( server ) { if ( serverInstance == null ) { synchronized ( BogusSslContextFactory . class ) { if ( serverInstance == null ) { try { serverInstance = createBougusServerSslContext ( ) ; } catch ( Exception ioe ) { throw new GeneralSecurityException ( "Can't create Server SSLContext:" + ioe ) ; } } } } retInstance = serverInstance ; } else { if ( clientInstance == null ) { synchronized ( BogusSslContextFactory . class ) { if ( clientInstance == null ) { clientInstance = createBougusClientSslContext ( ) ; } } } retInstance = clientInstance ; } return retInstance ; }
Get SSLContext singleton .
35,714
public void messageReceived ( Object message ) { if ( message instanceof Packet ) { try { messageReceived ( conn , ( Packet ) message ) ; } catch ( Exception e ) { log . warn ( "Exception on packet receive" , e ) ; } } else { IoBuffer in = ( IoBuffer ) message ; RTMP rtmp = conn . getState ( ) ; final byte connectionState = conn . getStateCode ( ) ; log . trace ( "connectionState: {}" , RTMP . states [ connectionState ] ) ; OutboundHandshake handshake = ( OutboundHandshake ) conn . getAttribute ( RTMPConnection . RTMP_HANDSHAKE ) ; switch ( connectionState ) { case RTMP . STATE_CONNECT : log . debug ( "Handshake - client phase 1 - size: {}" , in . remaining ( ) ) ; in . get ( ) ; byte handshakeType = in . get ( ) ; log . debug ( "Handshake - byte type: {}" , handshakeType ) ; byte [ ] s1 = new byte [ Constants . HANDSHAKE_SIZE ] ; in . get ( s1 ) ; IoBuffer out = handshake . decodeServerResponse1 ( IoBuffer . wrap ( s1 ) ) ; if ( out != null ) { rtmp . setState ( RTMP . STATE_HANDSHAKE ) ; conn . writeRaw ( out ) ; if ( in . remaining ( ) >= Constants . HANDSHAKE_SIZE ) { log . debug ( "Handshake - client phase 2 - size: {}" , in . remaining ( ) ) ; if ( handshake . decodeServerResponse2 ( in ) ) { } else { log . warn ( "Handshake failed on S2 processing" ) ; } conn . removeAttribute ( RTMPConnection . RTMP_HANDSHAKE ) ; conn . setStateCode ( RTMP . STATE_CONNECTED ) ; connectionOpened ( conn ) ; } } else { log . warn ( "Handshake failed on S0S1 processing" ) ; conn . close ( ) ; } break ; case RTMP . STATE_HANDSHAKE : log . debug ( "Handshake - client phase 2 - size: {}" , in . remaining ( ) ) ; if ( handshake . decodeServerResponse2 ( in ) ) { } else { log . warn ( "Handshake failed on S2 processing" ) ; } conn . removeAttribute ( RTMPConnection . RTMP_HANDSHAKE ) ; conn . setStateCode ( RTMP . STATE_CONNECTED ) ; connectionOpened ( conn ) ; break ; default : throw new IllegalStateException ( "Invalid RTMP state: " + connectionState ) ; } } }
Received message object router .
35,715
public void setConnection ( RTMPConnection conn ) { log . trace ( "Adding connection: {}" , conn ) ; int id = conn . getId ( ) ; if ( id == - 1 ) { log . debug ( "Connection has unsupported id, using session id hash" ) ; id = conn . getSessionId ( ) . hashCode ( ) ; } log . debug ( "Connection id: {} session id hash: {}" , conn . getId ( ) , conn . getSessionId ( ) . hashCode ( ) ) ; }
Adds a connection .
35,716
public RTMPConnection getConnection ( int clientId ) { log . trace ( "Getting connection by client id: {}" , clientId ) ; for ( RTMPConnection conn : connMap . values ( ) ) { if ( conn . getId ( ) == clientId ) { return connMap . get ( conn . getSessionId ( ) ) ; } } return null ; }
Returns a connection for a given client id .
35,717
public RTMPConnection getConnectionBySessionId ( String sessionId ) { log . debug ( "Getting connection by session id: {}" , sessionId ) ; if ( connMap . containsKey ( sessionId ) ) { return connMap . get ( sessionId ) ; } else { log . warn ( "Connection not found for {}" , sessionId ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Connections ({}) {}" , connMap . size ( ) , connMap . values ( ) ) ; } } return null ; }
Returns a connection for a given session id .
35,718
public RTMPConnection createConnectionInstance ( Class < ? > cls ) throws Exception { RTMPConnection conn = null ; if ( cls == RTMPMinaConnection . class ) { conn = ( RTMPMinaConnection ) cls . newInstance ( ) ; } else if ( cls == RTMPTClientConnection . class ) { conn = ( RTMPTClientConnection ) cls . newInstance ( ) ; } else { conn = ( RTMPConnection ) cls . newInstance ( ) ; } conn . setMaxHandshakeTimeout ( maxHandshakeTimeout ) ; conn . setMaxInactivity ( maxInactivity ) ; conn . setPingInterval ( pingInterval ) ; if ( enableTaskExecutor ) { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor ( ) ; executor . setCorePoolSize ( 1 ) ; executor . setDaemon ( true ) ; executor . setMaxPoolSize ( 1 ) ; executor . setQueueCapacity ( executorQueueCapacity ) ; executor . initialize ( ) ; conn . setExecutor ( executor ) ; } return conn ; }
Creates a connection instance based on the supplied type .
35,719
private IoBuffer encodeInvoke ( String method , Object [ ] params ) { log . debug ( "RemotingClient encodeInvoke - method: {} params: {}" , method , params ) ; IoBuffer result = IoBuffer . allocate ( 1024 ) ; result . setAutoExpand ( true ) ; result . putShort ( ( short ) 3 ) ; Collection < RemotingHeader > hdr = headers . values ( ) ; result . putShort ( ( short ) hdr . size ( ) ) ; for ( RemotingHeader header : hdr ) { Output . putString ( result , header . getName ( ) ) ; result . put ( header . getMustUnderstand ( ) ? ( byte ) 0x01 : ( byte ) 0x00 ) ; IoBuffer tmp = IoBuffer . allocate ( 1024 ) ; tmp . setAutoExpand ( true ) ; Output tmpOut = new Output ( tmp ) ; Serializer . serialize ( tmpOut , header . getValue ( ) ) ; tmp . flip ( ) ; result . putInt ( tmp . limit ( ) ) ; result . put ( tmp ) ; tmp . free ( ) ; tmp = null ; } result . putShort ( ( short ) 1 ) ; Output . putString ( result , method ) ; Output . putString ( result , "/" + sequenceCounter ++ ) ; IoBuffer tmp = IoBuffer . allocate ( 1024 ) ; tmp . setAutoExpand ( true ) ; Output tmpOut = new Output ( tmp ) ; if ( params == null ) { tmpOut . writeNull ( ) ; } else { tmpOut . writeArray ( params ) ; } tmp . flip ( ) ; result . putInt ( tmp . limit ( ) ) ; result . put ( tmp ) ; tmp . free ( ) ; tmp = null ; result . flip ( ) ; return result ; }
Encode the method call .
35,720
protected void processHeaders ( IoBuffer in ) { log . debug ( "RemotingClient processHeaders - buffer limit: {}" , ( in != null ? in . limit ( ) : 0 ) ) ; int version = in . getUnsignedShort ( ) ; log . debug ( "Version: {}" , version ) ; int count = in . getUnsignedShort ( ) ; log . debug ( "Count: {}" , count ) ; Input input = new Input ( in ) ; for ( int i = 0 ; i < count ; i ++ ) { String name = input . getString ( ) ; log . debug ( "Name: {}" , name ) ; boolean required = ( in . get ( ) == 0x01 ) ; log . debug ( "Required: {}" , required ) ; Object value = null ; int len = in . getInt ( ) ; log . debug ( "Length: {}" , len ) ; if ( len == - 1 ) { in . get ( ) ; len = in . getShort ( ) ; log . debug ( "Corrected length: {}" , len ) ; value = input . readString ( len ) ; } else { value = Deserializer . deserialize ( input , Object . class ) ; } log . debug ( "Value: {}" , value ) ; if ( RemotingHeader . APPEND_TO_GATEWAY_URL . equals ( name ) ) { appendToUrl = ( String ) value ; } else if ( RemotingHeader . REPLACE_GATEWAY_URL . equals ( name ) ) { url = ( String ) value ; } else if ( RemotingHeader . PERSISTENT_HEADER . equals ( name ) ) { if ( value instanceof Map < ? , ? > ) { @ SuppressWarnings ( "unchecked" ) Map < String , Object > valueMap = ( Map < String , Object > ) value ; RemotingHeader header = new RemotingHeader ( ( String ) valueMap . get ( "name" ) , ( Boolean ) valueMap . get ( "mustUnderstand" ) , valueMap . get ( "data" ) ) ; headers . put ( header . getName ( ) , header ) ; } else { log . error ( "Expected Map but received {}" , value ) ; } } else { log . warn ( "Unsupported remoting header \"{}\" received with value \"{}\"" , name , value ) ; } } }
Process any headers sent in the response .
35,721
@ SuppressWarnings ( "unused" ) private static final void dump ( IoBuffer data ) { log . debug ( "Hex: {}" , data . getHexDump ( ) ) ; int pos = data . position ( ) ; byte [ ] bar = new byte [ data . limit ( ) - data . position ( ) ] ; data . get ( bar ) ; log . debug ( "Str {}" , new String ( bar ) ) ; bar = null ; data . position ( pos ) ; }
Used for debugging byte stream .
35,722
private static void completeConnection ( IoSession session , RTMPMinaConnection conn , RTMP rtmp , OutboundHandshake handshake ) { if ( handshake . useEncryption ( ) ) { rtmp . setEncrypted ( true ) ; log . debug ( "Adding ciphers to the session" ) ; session . setAttribute ( RTMPConnection . RTMPE_CIPHER_IN , handshake . getCipherIn ( ) ) ; session . setAttribute ( RTMPConnection . RTMPE_CIPHER_OUT , handshake . getCipherOut ( ) ) ; } conn . getState ( ) . setState ( RTMP . STATE_CONNECTED ) ; log . debug ( "Connected, removing handshake data" ) ; session . removeAttribute ( RTMPConnection . RTMP_HANDSHAKE ) ; log . debug ( "Adding RTMP protocol filter" ) ; session . getFilterChain ( ) . addAfter ( "rtmpeFilter" , "protocolFilter" , new ProtocolCodecFilter ( new RTMPMinaCodecFactory ( ) ) ) ; BaseRTMPClientHandler handler = ( BaseRTMPClientHandler ) session . getAttribute ( RTMPConnection . RTMP_HANDLER ) ; handler . connectionOpened ( conn ) ; }
Provides connection completion .
35,723
public void setProtocol ( String protocol ) throws Exception { this . protocol = protocol ; if ( "rtmps" . equals ( protocol ) || "rtmpt" . equals ( protocol ) || "rtmpte" . equals ( protocol ) || "rtmfp" . equals ( protocol ) ) { throw new Exception ( "Unsupported protocol specified, please use the correct client for the intended protocol." ) ; } }
Sets the RTMP protocol the default is rtmp . If rtmps or rtmpt are required the appropriate client type should be selected .
35,724
public List < ? > decode ( IoBuffer data ) { log . debug ( "decode - state: {}" , state ) ; if ( closing || state . getState ( ) == RTMP . STATE_DISCONNECTED ) { return Collections . EMPTY_LIST ; } readBytes . addAndGet ( data . limit ( ) ) ; buffer . put ( data ) ; buffer . flip ( ) ; return decoder . decodeBuffer ( this , buffer ) ; }
Decode data sent by the client .
35,725
public void write ( final Packet packet ) { log . debug ( "write - state: {}" , state ) ; if ( closing || state . getState ( ) == RTMP . STATE_DISCONNECTED ) { return ; } IoBuffer data ; try { Red5 . setConnectionLocal ( this ) ; data = encoder . encode ( packet ) ; } catch ( Exception e ) { log . error ( "Could not encode message {}" , packet , e ) ; return ; } finally { Red5 . setConnectionLocal ( null ) ; } if ( data != null ) { writingMessage ( packet ) ; pendingMessages . add ( new PendingData ( data , packet ) ) ; } else { log . info ( "Response buffer was null after encoding" ) ; } }
Send RTMP packet down the connection .
35,726
public void connect ( String server , int port , String application , IPendingServiceCallback connectCallback ) { log . debug ( "connect server: {} port {} application {} connectCallback {}" , new Object [ ] { server , port , application , connectCallback } ) ; connect ( server , port , makeDefaultConnectionParams ( server , port , application ) , connectCallback ) ; }
Connect RTMP client to server s application via given port with given connection callback
35,727
public Map < String , Object > makeDefaultConnectionParams ( String server , int port , String application ) { Map < String , Object > params = new ObjectMap < > ( ) ; params . put ( "app" , application ) ; params . put ( "objectEncoding" , Integer . valueOf ( 0 ) ) ; params . put ( "fpad" , Boolean . FALSE ) ; params . put ( "flashVer" , "WIN 11,2,202,235" ) ; params . put ( "audioCodecs" , Integer . valueOf ( 3575 ) ) ; params . put ( "videoFunction" , Integer . valueOf ( 1 ) ) ; params . put ( "pageUrl" , null ) ; params . put ( "path" , application ) ; params . put ( "capabilities" , Integer . valueOf ( 15 ) ) ; params . put ( "swfUrl" , null ) ; params . put ( "videoCodecs" , Integer . valueOf ( 252 ) ) ; return params ; }
Creates the default connection parameters collection . Many implementations of this handler will create a tcUrl if not found it is created with the current server url .
35,728
public void connect ( String server , int port , Map < String , Object > connectionParams ) { log . debug ( "connect server: {} port {} connectionParams {}" , new Object [ ] { server , port , connectionParams } ) ; connect ( server , port , connectionParams , null ) ; }
Connect RTMP client to server via given port and with given connection parameters
35,729
public IClientSharedObject getSharedObject ( String name , boolean persistent ) { log . debug ( "getSharedObject name: {} persistent {}" , new Object [ ] { name , persistent } ) ; ClientSharedObject result = sharedObjects . get ( name ) ; if ( result != null ) { if ( result . isPersistent ( ) != persistent ) { throw new RuntimeException ( "Already connected to a shared object with this name, but with different persistence." ) ; } return result ; } result = new ClientSharedObject ( name , persistent ) ; sharedObjects . put ( name , result ) ; return result ; }
Connect to client shared object .
35,730
public void invoke ( String method , IPendingServiceCallback callback ) { log . debug ( "invoke method: {} params {} callback {}" , new Object [ ] { method , callback } ) ; if ( conn != null ) { conn . invoke ( method , callback ) ; } else { log . info ( "Connection was null" ) ; PendingCall result = new PendingCall ( method ) ; result . setStatus ( Call . STATUS_NOT_CONNECTED ) ; callback . resultReceived ( result ) ; } }
Invoke a method on the server .
35,731
public void disconnect ( ) { log . debug ( "disconnect" ) ; if ( conn != null ) { streamDataMap . clear ( ) ; conn . close ( ) ; } else { log . info ( "Connection was null" ) ; } }
Disconnect the first connection in the connection map
35,732
public void ping ( short pingType , Number streamId , int param ) { conn . ping ( new Ping ( pingType , streamId , param ) ) ; }
Sends a ping .
35,733
public void handleException ( Throwable throwable ) { log . debug ( "Handle exception: {} with: {}" , throwable . getMessage ( ) , exceptionHandler ) ; if ( exceptionHandler != null ) { exceptionHandler . handleException ( throwable ) ; } else { log . error ( "Connection exception" , throwable ) ; throw new RuntimeException ( throwable ) ; } }
Handle any exceptions that occur .
35,734
protected void createHandshakeBytes ( ) { log . trace ( "createHandshakeBytes" ) ; BigInteger bi = new BigInteger ( ( Constants . HANDSHAKE_SIZE * 8 ) , random ) ; handshakeBytes = BigIntegers . asUnsignedByteArray ( bi ) ; if ( handshakeBytes . length < Constants . HANDSHAKE_SIZE ) { ByteBuffer b = ByteBuffer . allocate ( Constants . HANDSHAKE_SIZE ) ; b . put ( handshakeBytes ) ; b . put ( ( byte ) 0x13 ) ; b . flip ( ) ; handshakeBytes = b . array ( ) ; } }
Creates the servers handshake bytes
35,735
private boolean getServerDigestPosition ( ) { boolean result = false ; log . trace ( "Trying algorithm: {}" , algorithm ) ; digestPosServer = getDigestOffset ( algorithm , s1 , 0 ) ; log . debug ( "Server digest position offset: {}" , digestPosServer ) ; if ( ! ( result = verifyDigest ( digestPosServer , s1 , GENUINE_FMS_KEY , 36 ) ) ) { algorithm ^= 1 ; log . trace ( "Trying algorithm: {}" , algorithm ) ; digestPosServer = getDigestOffset ( algorithm , s1 , 0 ) ; log . debug ( "Server digest position offset: {}" , digestPosServer ) ; if ( ! ( result = verifyDigest ( digestPosServer , s1 , GENUINE_FMS_KEY , 36 ) ) ) { log . warn ( "Server digest verification failed" ) ; if ( ! forceVerification ) { return true ; } } else { log . debug ( "Server digest verified" ) ; } } else { log . debug ( "Server digest verified" ) ; } return result ; }
Gets and verifies the server digest .
35,736
public void initSwfVerification ( String swfFilePath ) { log . info ( "Initializing swf verification for: {}" , swfFilePath ) ; byte [ ] bytes = null ; if ( swfFilePath != null ) { File localSwfFile = new File ( swfFilePath ) ; if ( localSwfFile . exists ( ) && localSwfFile . canRead ( ) ) { log . info ( "Swf file path: {}" , localSwfFile . getAbsolutePath ( ) ) ; bytes = FileUtil . readAsByteArray ( localSwfFile ) ; } else { bytes = "Red5 is awesome for handling non-accessable swf file" . getBytes ( ) ; } } else { bytes = new byte [ 42 ] ; } calculateHMAC_SHA256 ( bytes , 0 , bytes . length , GENUINE_FP_KEY , 30 , swfHash , 0 ) ; swfSize = bytes . length ; log . info ( "Verification - size: {}, hash: {}" , swfSize , Hex . encodeHexString ( swfHash ) ) ; }
Initialize SWF verification data .
35,737
public String getScopeValue ( Scope scope ) { logger . debug ( "Enter OAuth2config::getDefaultScope" ) ; return PropertiesConfig . getInstance ( ) . getProperty ( scope . value ( ) ) ; }
Returns the scope value based on the Enum supplied
35,738
public String prepareUrl ( List < Scope > scopes , String redirectUri , String csrfToken ) throws InvalidRequestException { logger . debug ( "Enter OAuth2config::prepareUrl" ) ; if ( scopes == null || scopes . isEmpty ( ) || redirectUri . isEmpty ( ) || csrfToken . isEmpty ( ) ) { logger . error ( "Invalid request for prepareUrl " ) ; throw new InvalidRequestException ( "Invalid request for prepareUrl" ) ; } try { return intuitAuthorizationEndpoint + "?client_id=" + clientId + "&response_type=code&scope=" + URLEncoder . encode ( buildScopeString ( scopes ) , "UTF-8" ) + "&redirect_uri=" + URLEncoder . encode ( redirectUri , "UTF-8" ) + "&state=" + csrfToken ; } catch ( UnsupportedEncodingException e ) { logger . error ( "Exception while preparing url for redirect " , e ) ; throw new InvalidRequestException ( e . getMessage ( ) , e ) ; } }
Prepares URL to call the OAuth2 authorization endpoint using Scope CSRF and redirectURL that is supplied
35,739
public static Date getCurrentDateTime ( ) throws ParseException { Calendar currentDate = Calendar . getInstance ( ) ; SimpleDateFormat formatter = new SimpleDateFormat ( DATE_yyyyMMddTHHmmssSSSZ ) ; String dateNow = formatter . format ( currentDate . getTime ( ) ) ; return getDateFromString ( dateNow ) ; }
Method to get the current date time Calendar instance
35,740
public static Date getDateWithPrevDays ( int noOfDays ) throws ParseException { Calendar currentDate = Calendar . getInstance ( ) ; currentDate . add ( Calendar . DATE , - noOfDays ) ; SimpleDateFormat formatter = new SimpleDateFormat ( DATE_yyyyMMddTHHmmssSSSZ ) ; String dateNow = formatter . format ( currentDate . getTime ( ) ) ; return getDateFromString ( dateNow ) ; }
Method to get the Date instance for the given days to be subtracted to the current date
35,741
public static String getStringFromDateTime ( Date date ) throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat ( DATE_yyyyMMddTHHmmssSSSZone ) ; return formatter . format ( date ) ; }
Method to convert the given Date to String format
35,742
public static ICompressor getCompressor ( final String compressFormat ) throws CompressionException { ICompressor compressor = null ; if ( isValidCompressFormat ( compressFormat ) ) { if ( compressFormat . equalsIgnoreCase ( GZIP_COMPRESS_FORMAT ) ) { compressor = new GZIPCompressor ( ) ; } else if ( compressFormat . equalsIgnoreCase ( DEFLATE_COMPRESS_FORMAT ) ) { compressor = new DeflateCompressor ( ) ; } } return compressor ; }
Method to get the corresponding compressor class for the given compress format
35,743
public static boolean isValidCompressFormat ( final String compressFormat ) throws CompressionException { if ( ! StringUtils . hasText ( compressFormat ) ) { throw new CompressionException ( "Compress format is either null or empty!" ) ; } else if ( compressFormat . equalsIgnoreCase ( GZIP_COMPRESS_FORMAT ) || compressFormat . equalsIgnoreCase ( DEFLATE_COMPRESS_FORMAT ) ) { return true ; } else { throw new CompressionException ( "There is no compression technique for the given compress format : " + compressFormat ) ; } }
Method to validate whether the given compression format is valid
35,744
public void executeAsyncInterceptors ( final IntuitMessage intuitMessage ) { this . intuitMessage = intuitMessage ; this . configuration = Config . cloneConfigurationOverrides ( ) ; ExecutorService executorService = Executors . newSingleThreadExecutor ( ) ; executorService . submit ( this ) ; }
Method to execute interceptors in case of Async operations .
35,745
public Void call ( ) throws FMSException { CallbackMessage callbackMessage = new CallbackMessage ( ) ; try { Config . addConfigurationOverrides ( configuration ) ; executeInterceptors ( intuitMessage ) ; } catch ( FMSException e ) { callbackMessage . setFMSException ( e ) ; LOG . error ( "Exception in interceptor flow" , e ) ; } intuitMessage . getResponseElements ( ) . setCallbackMessage ( callbackMessage ) ; new CallbackHandlerInterceptor ( ) . execute ( intuitMessage ) ; return null ; }
Callable interface method will be executed
35,746
public void invalidate ( ) { this . appToken = null ; this . appDBID = null ; this . authorizer = null ; this . intuitServiceType = null ; this . realmID = null ; }
Method to invalidate every fields in context .
35,747
public String getRequestID ( ) { if ( requestID == null ) { requestID = UUID . randomUUID ( ) . toString ( ) . replace ( "-" , "" ) ; } return requestID ; }
Method to generate unique requestID in the context of context
35,748
public static IEntitySerializer getSerializer ( final String serializeFormat ) throws SerializationException { IEntitySerializer serializer = null ; if ( isValidSerializeFormat ( serializeFormat ) ) { if ( serializeFormat . equalsIgnoreCase ( XML_SERIALIZE_FORMAT ) ) { serializer = new XMLSerializer ( ) ; } else if ( serializeFormat . equalsIgnoreCase ( JSON_SERIALIZE_FORMAT ) ) { serializer = new JSONSerializer ( ) ; } } return serializer ; }
Method to get the corresponding serialize instance for the given serializer format
35,749
public static boolean isValidSerializeFormat ( final String serializeFormat ) throws SerializationException { if ( ! StringUtils . hasText ( serializeFormat ) ) { throw new SerializationException ( "serialization format is either null or empty!" ) ; } else if ( serializeFormat . equalsIgnoreCase ( XML_SERIALIZE_FORMAT ) || serializeFormat . equalsIgnoreCase ( JSON_SERIALIZE_FORMAT ) ) { return true ; } else { throw new SerializationException ( "Serializer not supported for the given serialization format : " + serializeFormat ) ; } }
Method to validate whether the given serialization format is correct
35,750
public Charge create ( Charge charge ) throws BaseException { logger . debug ( "Enter ChargeService::create" ) ; String apiUrl = requestContext . getBaseUrl ( ) + "charges" . replaceAll ( "\\{format\\}" , "json" ) ; logger . info ( "apiUrl - " + apiUrl ) ; TypeReference < Charge > typeReference = new TypeReference < Charge > ( ) { } ; Request request = new Request . RequestBuilder ( MethodType . POST , apiUrl ) . requestObject ( charge ) . typeReference ( typeReference ) . context ( requestContext ) . build ( ) ; Response response = sendRequest ( request ) ; Charge chargeResponse = ( Charge ) response . getResponseObject ( ) ; prepareResponse ( request , response , chargeResponse ) ; return chargeResponse ; }
Method to create Charge
35,751
public Charge retrieve ( String chargeId ) throws BaseException { logger . debug ( "Enter ChargeService::retrieve" ) ; if ( StringUtils . isBlank ( chargeId ) ) { logger . error ( "IllegalArgumentException {}" , chargeId ) ; throw new IllegalArgumentException ( "chargeId cannot be empty or null" ) ; } String apiUrl = requestContext . getBaseUrl ( ) + "charges/{id}" . replaceAll ( "\\{format\\}" , "json" ) . replaceAll ( "\\{" + "id" + "\\}" , chargeId . toString ( ) ) ; logger . info ( "apiUrl - " + apiUrl ) ; TypeReference < Charge > typeReference = new TypeReference < Charge > ( ) { } ; Request request = new Request . RequestBuilder ( MethodType . GET , apiUrl ) . typeReference ( typeReference ) . context ( requestContext ) . build ( ) ; Response response = sendRequest ( request ) ; Charge chargeResponse = ( Charge ) response . getResponseObject ( ) ; prepareResponse ( request , response , chargeResponse ) ; return chargeResponse ; }
Method to retrieve Charge
35,752
public Expression < Byte > eq ( byte value ) { String valueString = "'" + value + "'" ; return new Expression < Byte > ( this , Operation . eq , valueString ) ; }
Method to construct the equals expression for byte
35,753
public Expression < Short > eq ( short value ) { String valueString = "'" + value + "'" ; return new Expression < Short > ( this , Operation . eq , valueString ) ; }
Method to construct the equals expression for short
35,754
public Expression < Integer > eq ( int value ) { String valueString = "'" + value + "'" ; return new Expression < Integer > ( this , Operation . eq , valueString ) ; }
Method to construct the equals expression for integer
35,755
public Expression < Long > eq ( long value ) { String valueString = "'" + value + "'" ; return new Expression < Long > ( this , Operation . eq , valueString ) ; }
Method to construct the equals expression for long
35,756
public Expression < Float > eq ( float value ) { String valueString = "'" + value + "'" ; return new Expression < Float > ( this , Operation . eq , valueString ) ; }
Method to construct the equals expression for float
35,757
public Expression < Double > eq ( double value ) { String valueString = "'" + value + "'" ; return new Expression < Double > ( this , Operation . eq , valueString ) ; }
Method to construct the equals expression for double
35,758
public Expression < Byte > neq ( byte value ) { String valueString = "'" + value + "'" ; return new Expression < Byte > ( this , Operation . neq , valueString ) ; }
Method to construct the not equals expression for byte
35,759
public Expression < Short > neq ( short value ) { String valueString = "'" + value + "'" ; return new Expression < Short > ( this , Operation . neq , valueString ) ; }
Method to construct the not equals expression for short
35,760
public Expression < Integer > neq ( int value ) { String valueString = "'" + value + "'" ; return new Expression < Integer > ( this , Operation . neq , valueString ) ; }
Method to construct the not equals expression for int
35,761
public Expression < Long > neq ( long value ) { String valueString = "'" + value + "'" ; return new Expression < Long > ( this , Operation . neq , valueString ) ; }
Method to construct the not equals expression for long
35,762
public Expression < Float > neq ( float value ) { String valueString = "'" + value + "'" ; return new Expression < Float > ( this , Operation . neq , valueString ) ; }
Method to construct the not equals expression for float
35,763
public Expression < Double > neq ( double value ) { String valueString = "'" + value + "'" ; return new Expression < Double > ( this , Operation . neq , valueString ) ; }
Method to construct the not equals expression for double
35,764
public Expression < Byte > lt ( byte value ) { String valueString = "'" + value + "'" ; return new Expression < Byte > ( this , Operation . lt , valueString ) ; }
Method to construct the less than expression for byte
35,765
public Expression < Short > lt ( short value ) { String valueString = "'" + value + "'" ; return new Expression < Short > ( this , Operation . lt , valueString ) ; }
Method to construct the less than expression for short
35,766
public Expression < Integer > lt ( int value ) { String valueString = "'" + value + "'" ; return new Expression < Integer > ( this , Operation . lt , valueString ) ; }
Method to construct the less than expression for int
35,767
public Expression < Long > lt ( long value ) { String valueString = "'" + value + "'" ; return new Expression < Long > ( this , Operation . lt , valueString ) ; }
Method to construct the less than expression for long
35,768
public Expression < Float > lt ( float value ) { String valueString = "'" + value + "'" ; return new Expression < Float > ( this , Operation . lt , valueString ) ; }
Method to construct the less than expression for float
35,769
public Expression < Double > lt ( double value ) { String valueString = "'" + value + "'" ; return new Expression < Double > ( this , Operation . lt , valueString ) ; }
Method to construct the less than expression for double
35,770
public Expression < Byte > lte ( byte value ) { String valueString = "'" + value + "'" ; return new Expression < Byte > ( this , Operation . lte , valueString ) ; }
Method to construct the less than or equals expression for byte
35,771
public Expression < Short > lte ( short value ) { String valueString = "'" + value + "'" ; return new Expression < Short > ( this , Operation . lte , valueString ) ; }
Method to construct the less than or equals expression for short
35,772
public Expression < Integer > lte ( int value ) { String valueString = "'" + value + "'" ; return new Expression < Integer > ( this , Operation . lte , valueString ) ; }
Method to construct the less than or equals expression for int
35,773
public Expression < Long > lte ( long value ) { String valueString = "'" + value + "'" ; return new Expression < Long > ( this , Operation . lte , valueString ) ; }
Method to construct the less than or equals expression for long
35,774
public Expression < Float > lte ( float value ) { String valueString = "'" + value + "'" ; return new Expression < Float > ( this , Operation . lte , valueString ) ; }
Method to construct the less than or equals expression for float
35,775
public Expression < Double > lte ( double value ) { String valueString = "'" + value + "'" ; return new Expression < Double > ( this , Operation . lte , valueString ) ; }
Method to construct the less than or equals expression for double
35,776
public Expression < Byte > gt ( byte value ) { String valueString = "'" + value + "'" ; return new Expression < Byte > ( this , Operation . gt , valueString ) ; }
Method to construct the greater than expression for byte
35,777
public Expression < Short > gt ( short value ) { String valueString = "'" + value + "'" ; return new Expression < Short > ( this , Operation . gt , valueString ) ; }
Method to construct the greater than expression for short
35,778
public Expression < Integer > gt ( int value ) { String valueString = "'" + value + "'" ; return new Expression < Integer > ( this , Operation . gt , valueString ) ; }
Method to construct the greater than expression for int
35,779
public Expression < Long > gt ( long value ) { String valueString = "'" + value + "'" ; return new Expression < Long > ( this , Operation . gt , valueString ) ; }
Method to construct the greater than expression for long
35,780
public Expression < Float > gt ( float value ) { String valueString = "'" + value + "'" ; return new Expression < Float > ( this , Operation . gt , valueString ) ; }
Method to construct the greater than expression for float
35,781
public Expression < Double > gt ( double value ) { String valueString = "'" + value + "'" ; return new Expression < Double > ( this , Operation . gt , valueString ) ; }
Method to construct the greater than expression for double
35,782
public Expression < Byte > gte ( byte value ) { String valueString = "'" + value + "'" ; return new Expression < Byte > ( this , Operation . gte , valueString ) ; }
Method to construct the greater than or equals expression for byte
35,783
public Expression < Short > gte ( short value ) { String valueString = "'" + value + "'" ; return new Expression < Short > ( this , Operation . gte , valueString ) ; }
Method to construct the greater than or equals expression for short
35,784
public Expression < Integer > gte ( int value ) { String valueString = "'" + value + "'" ; return new Expression < Integer > ( this , Operation . gte , valueString ) ; }
Method to construct the greater than or equals expression for int
35,785
public Expression < Long > gte ( long value ) { String valueString = "'" + value + "'" ; return new Expression < Long > ( this , Operation . gte , valueString ) ; }
Method to construct the greater than or equals expression for long
35,786
public Expression < Float > gte ( float value ) { String valueString = "'" + value + "'" ; return new Expression < Float > ( this , Operation . gte , valueString ) ; }
Method to construct the greater than or equals expression for float
35,787
public Expression < Double > gte ( double value ) { String valueString = "'" + value + "'" ; return new Expression < Double > ( this , Operation . gte , valueString ) ; }
Method to construct the greater than or equals expression for double
35,788
public Expression < Byte > in ( Byte [ ] value ) { String listNumberString = "" ; Boolean firstNumber = true ; for ( Byte v : value ) { if ( firstNumber ) { listNumberString = listNumberString . concat ( "('" ) . concat ( v . toString ( ) ) . concat ( "'" ) ; firstNumber = false ; } else { listNumberString = listNumberString . concat ( ", '" ) . concat ( v . toString ( ) ) . concat ( "'" ) ; } } listNumberString = listNumberString . concat ( ")" ) ; return new Expression < Byte > ( this , Operation . in , listNumberString ) ; }
Method to construct the in expression for byte
35,789
public Expression < Byte > between ( Byte startValue , Byte endValue ) { String valueString = "'" + startValue + "' AND '" + endValue + "'" ; return new Expression < Byte > ( this , Operation . between , valueString ) ; }
Method to construct the between expression for byte
35,790
public Expression < Short > between ( Short startValue , Short endValue ) { String valueString = "'" + startValue + "' AND '" + endValue + "'" ; return new Expression < Short > ( this , Operation . between , valueString ) ; }
Method to construct the between expression for short
35,791
public Expression < Integer > between ( Integer startValue , Integer endValue ) { String valueString = "'" + startValue + "' AND '" + endValue + "'" ; return new Expression < Integer > ( this , Operation . between , valueString ) ; }
Method to construct the between expression for integer
35,792
public Expression < Long > between ( Long startValue , Long endValue ) { String valueString = "'" + startValue + "' AND '" + endValue + "'" ; return new Expression < Long > ( this , Operation . between , valueString ) ; }
Method to construct the between expression for long
35,793
public Expression < Float > between ( Float startValue , Float endValue ) { String valueString = "'" + startValue + "' AND '" + endValue + "'" ; return new Expression < Float > ( this , Operation . between , valueString ) ; }
Method to construct the between expression for float
35,794
public Expression < Double > between ( Double startValue , Double endValue ) { String valueString = "'" + startValue + "' AND '" + endValue + "'" ; return new Expression < Double > ( this , Operation . between , valueString ) ; }
Method to construct the between expression for double
35,795
public boolean retryRequest ( IOException exception , int executionCount , HttpContext context ) { LOG . debug ( "In retry request" ) ; if ( exception == null ) { throw new IllegalArgumentException ( "Exception parameter may not be null" ) ; } else if ( context == null ) { throw new IllegalArgumentException ( "HTTP context may not be null" ) ; } if ( executionCount > this . retryCount ) { return checkPolicy ( executionCount ) ; } else if ( exception instanceof NoHttpResponseException ) { return checkPolicy ( executionCount ) ; } else if ( exception instanceof InterruptedIOException ) { return false ; } else if ( exception instanceof UnknownHostException ) { return false ; } else if ( exception instanceof ConnectException ) { return false ; } else if ( exception instanceof SSLException ) { return false ; } else if ( exception instanceof ProtocolException ) { return false ; } else if ( exception instanceof SaslException ) { return false ; } HttpRequest request = ( HttpRequest ) context . getAttribute ( HttpCoreContext . HTTP_REQUEST ) ; boolean idempotent = ! ( request instanceof HttpEntityEnclosingRequest ) ; if ( idempotent ) { return checkPolicy ( executionCount ) ; } Boolean b = ( Boolean ) context . getAttribute ( HttpCoreContext . HTTP_REQ_SENT ) ; boolean sent = ( b != null && b . booleanValue ( ) ) ; if ( ! sent ) { return checkPolicy ( executionCount ) ; } return false ; }
method to validate the retry policies
35,796
private boolean checkPolicy ( int executionCount ) { if ( mechanism . equalsIgnoreCase ( "fixedretry" ) ) { if ( this . retryCount == 0 ) { return false ; } else if ( executionCount < this . retryCount ) { try { Thread . sleep ( ( long ) this . retryInterval ) ; LOG . debug ( "The retryInterval " + this . retryInterval ) ; return true ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) ) ; } } return false ; } if ( mechanism . equalsIgnoreCase ( "incrementalretry" ) ) { if ( executionCount < this . retryCount ) { try { Thread . sleep ( ( long ) this . initialInterval + ( this . increment * executionCount ) ) ; return true ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) ) ; } } return false ; } if ( mechanism . equalsIgnoreCase ( "exponentialretry" ) ) { if ( executionCount < this . retryCount ) { try { int delta = ( int ) ( ( Math . pow ( 2.0 , executionCount ) - 1.0 ) * ( this . deltaBackoff * NUM_0_8 ) + ( Math . random ( ) * ( this . deltaBackoff * NUM_1_2 ) - ( this . deltaBackoff * NUM_0_8 ) + 1 ) ) ; int interval = ( int ) Math . min ( ( this . minBackoff + delta ) , this . maxBackoff ) ; Thread . sleep ( interval ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) ) ; } return true ; } return false ; } return true ; }
Method to check the retry request policy
35,797
public BearerTokenResponse refreshToken ( String refreshToken ) throws OAuthException { logger . debug ( "Enter OAuth2PlatformClient::refreshToken" ) ; try { HttpRequestClient client = new HttpRequestClient ( oauth2Config . getProxyConfig ( ) ) ; Request request = new Request . RequestBuilder ( MethodType . POST , oauth2Config . getIntuitBearerTokenEndpoint ( ) ) . requiresAuthentication ( true ) . authString ( getAuthHeader ( ) ) . postParams ( getUrlParameters ( "refresh" , refreshToken , null ) ) . build ( ) ; Response response = client . makeRequest ( request ) ; logger . debug ( "Response Code : " + response . getStatusCode ( ) ) ; if ( response . getStatusCode ( ) != 200 ) { logger . debug ( "failed getting access token" ) ; throw new OAuthException ( "failed getting access token" , response . getStatusCode ( ) + "" ) ; } ObjectReader reader = mapper . readerFor ( BearerTokenResponse . class ) ; BearerTokenResponse bearerTokenResponse = reader . readValue ( response . getContent ( ) ) ; return bearerTokenResponse ; } catch ( Exception ex ) { logger . error ( "Exception while calling refreshToken " , ex ) ; throw new OAuthException ( ex . getMessage ( ) , ex ) ; } }
Method to renew OAuth2 tokens by passing the refreshToken
35,798
private List < NameValuePair > getUrlParameters ( String action , String token , String redirectUri ) { List < NameValuePair > urlParameters = new ArrayList < NameValuePair > ( ) ; if ( action == "revoke" ) { urlParameters . add ( new BasicNameValuePair ( "token" , token ) ) ; } else if ( action == "refresh" ) { urlParameters . add ( new BasicNameValuePair ( "refresh_token" , token ) ) ; urlParameters . add ( new BasicNameValuePair ( "grant_type" , "refresh_token" ) ) ; } else { urlParameters . add ( new BasicNameValuePair ( "code" , token ) ) ; urlParameters . add ( new BasicNameValuePair ( "redirect_uri" , redirectUri ) ) ; urlParameters . add ( new BasicNameValuePair ( "grant_type" , "authorization_code" ) ) ; } return urlParameters ; }
Method to build post parameters
35,799
public PlatformResponse revokeToken ( String token ) throws ConnectionException { logger . debug ( "Enter OAuth2PlatformClient::revokeToken" ) ; PlatformResponse platformResponse = new PlatformResponse ( ) ; try { HttpRequestClient client = new HttpRequestClient ( oauth2Config . getProxyConfig ( ) ) ; Request request = new Request . RequestBuilder ( MethodType . POST , oauth2Config . getIntuitRevokeTokenEndpoint ( ) ) . requiresAuthentication ( true ) . authString ( getAuthHeader ( ) ) . postParams ( getUrlParameters ( "revoke" , token , null ) ) . build ( ) ; Response response = client . makeRequest ( request ) ; logger . debug ( "Response Code : " + response . getStatusCode ( ) ) ; if ( response . getStatusCode ( ) != 200 ) { logger . debug ( "failed to revoke token" ) ; platformResponse . setStatus ( "ERROR" ) ; platformResponse . setErrorCode ( response . getStatusCode ( ) + "" ) ; platformResponse . setErrorMessage ( "Failed to revoke token" ) ; return platformResponse ; } platformResponse . setStatus ( "SUCCESS" ) ; return platformResponse ; } catch ( Exception ex ) { logger . error ( "Exception while calling revokeToken " , ex ) ; throw new ConnectionException ( ex . getMessage ( ) , ex ) ; } }
Method to revoke OAuth2 tokens