idx
int64 0
41.2k
| question
stringlengths 83
4.15k
| target
stringlengths 5
715
|
|---|---|---|
3,800
|
public synchronized int read ( int plane , byte data [ ] , int offset , int length ) throws IOException { if ( offset < 0 || length < 0 || length > data . length - offset ) throw new IndexOutOfBoundsException ( ) ; if ( bytesToRead [ plane ] == 0 ) return 0 ; if ( bytesToRead [ plane ] < length ) length = bytesToRead [ plane ] ; buffer [ plane ] . position ( readPointer [ plane ] ) ; int partLength = buffer [ plane ] . capacity ( ) - readPointer [ plane ] ; if ( partLength > length ) { buffer [ plane ] . get ( data , offset , length ) ; readPointer [ plane ] += length ; } else { buffer [ plane ] . get ( data , offset , partLength ) ; buffer [ plane ] . position ( 0 ) ; buffer [ plane ] . get ( data , partLength , length - partLength ) ; readPointer [ plane ] = length - partLength ; } bytesToRead [ plane ] -= length ; bytesToWrite [ plane ] += length ; return length ; }
|
Read as much data as possible from this buffer .
|
3,801
|
public void clear ( ) { if ( planePointers != null ) { for ( int i = 0 ; i < getPlaneCount ( ) ; i ++ ) { av_free ( planePointers [ i ] . position ( 0 ) ) ; } planePointers = null ; } }
|
Free the memory of sample buffers .
|
3,802
|
public void open ( int width , int height , double frameRate ) throws JavaAVException { if ( ! open . get ( ) ) { String input = "video=" + device ; demuxer = new Demuxer ( ) ; demuxer . setInputFormat ( format ) ; demuxer . setImageWidth ( width ) ; demuxer . setImageHeight ( height ) ; demuxer . setFramerate ( frameRate ) ; demuxer . open ( input ) ; open . set ( true ) ; } }
|
Open the camera with specified image size and capture frame rate .
|
3,803
|
public void visit ( ASTNode [ ] nodes , SourceUnit sourceUnit ) { if ( ! ( nodes [ 0 ] instanceof AnnotationNode ) || ! ( nodes [ 1 ] instanceof AnnotatedNode ) ) { throw new IllegalArgumentException ( "Internal error: wrong types: " + nodes [ 0 ] . getClass ( ) . getName ( ) + " / " + nodes [ 1 ] . getClass ( ) . getName ( ) ) ; } AnnotationNode node = ( AnnotationNode ) nodes [ 0 ] ; AnnotatedNode parent = ( AnnotatedNode ) nodes [ 1 ] ; ClassNode declaringClass = parent . getDeclaringClass ( ) ; if ( parent instanceof FieldNode ) { int modifiers = ( ( FieldNode ) parent ) . getModifiers ( ) ; if ( ( modifiers & Modifier . FINAL ) != 0 ) { String msg = "@griffon.transform.FXBindable cannot annotate a final property." ; generateSyntaxErrorMessage ( sourceUnit , node , msg ) ; } addJavaFXProperty ( sourceUnit , node , declaringClass , ( FieldNode ) parent ) ; } else { addJavaFXPropertyToClass ( sourceUnit , node , ( ClassNode ) parent ) ; } }
|
This ASTTransformation method is called when the compiler encounters our annotation .
|
3,804
|
private void addJavaFXPropertyToClass ( SourceUnit source , AnnotationNode node , ClassNode classNode ) { for ( PropertyNode propertyNode : classNode . getProperties ( ) ) { FieldNode field = propertyNode . getField ( ) ; if ( hasFXBindableAnnotation ( field ) || ( ( field . getModifiers ( ) & Modifier . FINAL ) != 0 ) || field . isStatic ( ) ) { continue ; } createPropertyGetterSetter ( classNode , propertyNode ) ; } }
|
Iterate through the properties of the class and convert each eligible property to a JavaFX property .
|
3,805
|
protected void createGetterMethod ( ClassNode declaringClass , PropertyNode propertyNode , String getterName , Statement getterBlock , List < AnnotationNode > annotations ) { int mod = propertyNode . getModifiers ( ) | Modifier . FINAL ; MethodNode getter = new MethodNode ( getterName , mod , propertyNode . getType ( ) , Parameter . EMPTY_ARRAY , ClassNode . EMPTY_ARRAY , getterBlock ) ; if ( annotations != null ) getter . addAnnotations ( annotations ) ; getter . setSynthetic ( true ) ; declaringClass . addMethod ( getter ) ; }
|
Creates a getter method and adds it to the declaring class .
|
3,806
|
private void generateSyntaxErrorMessage ( SourceUnit sourceUnit , AnnotationNode node , String msg ) { SyntaxException error = new SyntaxException ( msg , node . getLineNumber ( ) , node . getColumnNumber ( ) ) ; sourceUnit . getErrorCollector ( ) . addErrorAndContinue ( new SyntaxErrorMessage ( error , sourceUnit ) ) ; }
|
Generates a SyntaxErrorMessage based on the current SourceUnit AnnotationNode and a specified error message .
|
3,807
|
private FieldNode createFieldNodeCopy ( String newName , ClassNode newType , FieldNode f ) { if ( newType == null ) newType = f . getType ( ) ; newType = newType . getPlainNodeReference ( ) ; return new FieldNode ( newName , f . getModifiers ( ) , newType , f . getOwner ( ) , f . getInitialValueExpression ( ) ) ; }
|
Creates a copy of a FieldNode with a new name and optionally a new type .
|
3,808
|
protected void onLayout ( boolean changed , int l , int t , int r , int b ) { super . onLayout ( changed , l , t , r , b ) ; if ( mAdjustViewSize ) { if ( ! ( getParent ( ) instanceof RelativeLayout ) ) { throw new IllegalStateException ( "Only RelativeLayout is supported as parent of this view" ) ; } final int sWidth = ScreenHelper . getScreenWidth ( getContext ( ) ) ; final int sHeight = ScreenHelper . getScreenHeight ( getContext ( ) ) ; RelativeLayout . LayoutParams params = ( RelativeLayout . LayoutParams ) getLayoutParams ( ) ; params . width = ( int ) ( sWidth * mButtonMenu . getMainButtonSize ( ) ) ; params . height = ( int ) ( sWidth * mButtonMenu . getMainButtonSize ( ) ) ; params . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * mButtonMenu . getBottomPadding ( ) ) ) ; } }
|
Adjusts size of this view to match the underlying button menu . This allows a smooth transition between this view and the close button behind it .
|
3,809
|
public View getMenuButton ( MenuButton button ) { switch ( button ) { case MID : return mMidContainer ; case LEFT : return mLeftContainer ; case RIGHT : return mRightContainer ; } return null ; }
|
Returns the menu button container . The first child of the container is a TextView the second - an ImageButton
|
3,810
|
public void setMenuTextAppearance ( int appearanceResource ) { mLeftText . setTextAppearance ( getContext ( ) , appearanceResource ) ; mMidText . setTextAppearance ( getContext ( ) , appearanceResource ) ; mRightText . setTextAppearance ( getContext ( ) , appearanceResource ) ; }
|
Set text appearance for button text views
|
3,811
|
public void setMenuButtonImage ( MenuButton button , Drawable drawable ) { switch ( button ) { case MID : mMidBtn . setImageDrawable ( drawable ) ; break ; case LEFT : mLeftBtn . setImageDrawable ( drawable ) ; break ; case RIGHT : mRightBtn . setImageDrawable ( drawable ) ; break ; } }
|
Set image drawable for a menu button
|
3,812
|
public void setMenuButtonText ( MenuButton button , String text ) { switch ( button ) { case MID : mMidText . setText ( text ) ; break ; case LEFT : mLeftText . setText ( text ) ; break ; case RIGHT : mRightText . setText ( text ) ; break ; } }
|
Set text displayed under a menu button
|
3,813
|
private void inflate ( ) { ( ( LayoutInflater ) getContext ( ) . getSystemService ( Context . LAYOUT_INFLATER_SERVICE ) ) . inflate ( R . layout . ebm__menu , this , true ) ; mOverlay = findViewById ( R . id . ebm__menu_overlay ) ; mMidContainer = findViewById ( R . id . ebm__menu_middle_container ) ; mLeftContainer = findViewById ( R . id . ebm__menu_left_container ) ; mRightContainer = findViewById ( R . id . ebm__menu_right_container ) ; mMidText = ( TextView ) findViewById ( R . id . ebm__menu_middle_text ) ; mLeftText = ( TextView ) findViewById ( R . id . ebm__menu_left_text ) ; mRightText = ( TextView ) findViewById ( R . id . ebm__menu_right_text ) ; mCloseBtn = ( ImageButton ) findViewById ( R . id . ebm__menu_close_image ) ; mMidBtn = ( ImageButton ) findViewById ( R . id . ebm__menu_middle_image ) ; mRightBtn = ( ImageButton ) findViewById ( R . id . ebm__menu_right_image ) ; mLeftBtn = ( ImageButton ) findViewById ( R . id . ebm__menu_left_image ) ; sWidth = ScreenHelper . getScreenWidth ( getContext ( ) ) ; sHeight = ScreenHelper . getScreenHeight ( getContext ( ) ) ; mMidBtn . setEnabled ( false ) ; mRightBtn . setEnabled ( false ) ; mLeftBtn . setEnabled ( false ) ; mCloseBtn . setOnClickListener ( this ) ; mMidBtn . setOnClickListener ( this ) ; mRightBtn . setOnClickListener ( this ) ; mLeftBtn . setOnClickListener ( this ) ; mOverlay . setOnClickListener ( this ) ; }
|
Inflates the view
|
3,814
|
private void parseAttributes ( AttributeSet attrs ) { if ( attrs != null ) { TypedArray a = getContext ( ) . getTheme ( ) . obtainStyledAttributes ( attrs , R . styleable . ExpandableMenuOverlay , 0 , 0 ) ; try { mainButtonSize = a . getFloat ( R . styleable . ExpandableMenuOverlay_mainButtonSize , DEFAULT_MAIN_BUTTON_SIZE ) ; otherButtonSize = a . getFloat ( R . styleable . ExpandableMenuOverlay_otherButtonSize , DEFAULT_OTHER_BUTTON_SIZE ) ; bottomPadding = a . getFloat ( R . styleable . ExpandableMenuOverlay_bottomPad , DEFAULT_BOTTOM_PADDING ) ; buttonDistanceY = a . getFloat ( R . styleable . ExpandableMenuOverlay_distanceY , DEFAULT_BUTTON_DISTANCE_Y ) ; buttonDistanceX = a . getFloat ( R . styleable . ExpandableMenuOverlay_distanceX , DEFAULT_BUTTON_DISTANCE_X ) ; mCloseBtn . setBackgroundResource ( a . getResourceId ( R . styleable . ExpandableMenuOverlay_closeButtonSrc , 0 ) ) ; mLeftBtn . setBackgroundResource ( a . getResourceId ( R . styleable . ExpandableMenuOverlay_leftButtonSrc , 0 ) ) ; mRightBtn . setBackgroundResource ( a . getResourceId ( R . styleable . ExpandableMenuOverlay_rightButtonSrc , 0 ) ) ; mMidBtn . setBackgroundResource ( a . getResourceId ( R . styleable . ExpandableMenuOverlay_midButtonSrc , 0 ) ) ; mLeftText . setText ( a . getResourceId ( R . styleable . ExpandableMenuOverlay_leftButtonText , R . string . empty ) ) ; mRightText . setText ( a . getResourceId ( R . styleable . ExpandableMenuOverlay_rightButtonText , R . string . empty ) ) ; mMidText . setText ( a . getResourceId ( R . styleable . ExpandableMenuOverlay_midButtonText , R . string . empty ) ) ; } finally { a . recycle ( ) ; } } }
|
Parses custom XML attributes
|
3,815
|
private void setViewLayoutParams ( ) { final int EXTRA_MARGIN = ( int ) ( sWidth * ( mainButtonSize - otherButtonSize ) / 2 ) ; Log . d ( TAG , "otherButton: " + otherButtonSize ) ; Log . d ( TAG , "mainButton: " + mainButtonSize ) ; RelativeLayout . LayoutParams rParams = ( LayoutParams ) mCloseBtn . getLayoutParams ( ) ; rParams . width = ( int ) ( sWidth * otherButtonSize ) ; rParams . height = ( int ) ( sWidth * otherButtonSize ) ; rParams . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * bottomPadding + EXTRA_MARGIN ) ) ; rParams = ( LayoutParams ) mMidContainer . getLayoutParams ( ) ; rParams . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * bottomPadding + EXTRA_MARGIN ) ) ; rParams = ( LayoutParams ) mRightContainer . getLayoutParams ( ) ; rParams . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * bottomPadding + EXTRA_MARGIN ) ) ; rParams = ( LayoutParams ) mLeftContainer . getLayoutParams ( ) ; rParams . setMargins ( 0 , 0 , 0 , ( int ) ( sHeight * bottomPadding + EXTRA_MARGIN ) ) ; LinearLayout . LayoutParams params = ( LinearLayout . LayoutParams ) mMidBtn . getLayoutParams ( ) ; params . width = ( int ) ( sWidth * otherButtonSize ) ; params . height = ( int ) ( sWidth * otherButtonSize ) ; params = ( LinearLayout . LayoutParams ) mRightBtn . getLayoutParams ( ) ; params . width = ( int ) ( sWidth * otherButtonSize ) ; params . height = ( int ) ( sWidth * otherButtonSize ) ; params = ( LinearLayout . LayoutParams ) mLeftBtn . getLayoutParams ( ) ; params . width = ( int ) ( sWidth * otherButtonSize ) ; params . height = ( int ) ( sWidth * otherButtonSize ) ; }
|
Initialized the layout of menu buttons . Sets button sizes and distances between them by a % of screen width or height accordingly . Some extra padding between buttons is added by default to avoid intersections .
|
3,816
|
private void calculateAnimationProportions ( ) { TRANSLATION_Y = sHeight * buttonDistanceY ; TRANSLATION_X = sWidth * buttonDistanceX ; anticipation = new AnticipateInterpolator ( INTERPOLATOR_WEIGHT ) ; overshoot = new OvershootInterpolator ( INTERPOLATOR_WEIGHT ) ; }
|
Initialized animation properties
|
3,817
|
private void animateExpand ( ) { mCloseBtn . setVisibility ( View . VISIBLE ) ; mMidContainer . setVisibility ( View . VISIBLE ) ; mRightContainer . setVisibility ( View . VISIBLE ) ; mLeftContainer . setVisibility ( View . VISIBLE ) ; setButtonsVisibleForPreHC ( ) ; ANIMATION_COUNTER = 0 ; ViewPropertyAnimator . animate ( mMidContainer ) . setDuration ( ANIMATION_DURATION ) . translationYBy ( - TRANSLATION_Y ) . setInterpolator ( overshoot ) . setListener ( ON_EXPAND_COLLAPSE_LISTENER ) ; ViewPropertyAnimator . animate ( mRightContainer ) . setDuration ( ANIMATION_DURATION ) . translationYBy ( - TRANSLATION_Y ) . translationXBy ( TRANSLATION_X ) . setInterpolator ( overshoot ) . setListener ( ON_EXPAND_COLLAPSE_LISTENER ) ; ViewPropertyAnimator . animate ( mLeftContainer ) . setDuration ( ANIMATION_DURATION ) . translationYBy ( - TRANSLATION_Y ) . translationXBy ( - TRANSLATION_X ) . setInterpolator ( overshoot ) . setListener ( ON_EXPAND_COLLAPSE_LISTENER ) ; }
|
Start expand animation
|
3,818
|
private void animateCollapse ( ) { mCloseBtn . setVisibility ( View . VISIBLE ) ; ANIMATION_COUNTER = 0 ; ViewPropertyAnimator . animate ( mMidContainer ) . setDuration ( ANIMATION_DURATION ) . translationYBy ( TRANSLATION_Y ) . setInterpolator ( anticipation ) . setListener ( ON_EXPAND_COLLAPSE_LISTENER ) ; ViewPropertyAnimator . animate ( mRightContainer ) . setDuration ( ANIMATION_DURATION ) . translationYBy ( TRANSLATION_Y ) . translationXBy ( - TRANSLATION_X ) . setInterpolator ( anticipation ) . setListener ( ON_EXPAND_COLLAPSE_LISTENER ) ; ViewPropertyAnimator . animate ( mLeftContainer ) . setDuration ( ANIMATION_DURATION ) . translationYBy ( TRANSLATION_Y ) . translationXBy ( TRANSLATION_X ) . setInterpolator ( anticipation ) . setListener ( ON_EXPAND_COLLAPSE_LISTENER ) ; }
|
Start collapse animation
|
3,819
|
private void setButtonsVisibleForPreHC ( ) { if ( android . os . Build . VERSION . SDK_INT < Build . VERSION_CODES . HONEYCOMB ) { ViewHelper . setAlpha ( mMidContainer , 1.0f ) ; ViewHelper . setAlpha ( mLeftContainer , 1.0f ) ; ViewHelper . setAlpha ( mRightContainer , 1.0f ) ; } }
|
Hide views for pre - Honeycomb devices
|
3,820
|
private boolean validateNoLoopDetected ( DefaultHttpSession acceptSession ) { List < String > viaHeaders = acceptSession . getReadHeaders ( HEADER_VIA ) ; if ( viaHeaders != null && viaHeaders . stream ( ) . anyMatch ( h -> h . equals ( viaHeader ) ) ) { LOGGER . warn ( "Connection to " + getConnectURIs ( ) . iterator ( ) . next ( ) + " failed due to loop detection [" + acceptSession + "->]" ) ; acceptSession . setStatus ( HttpStatus . SERVER_LOOP_DETECTED ) ; acceptSession . close ( true ) ; return false ; } return true ; }
|
Helper method performing loop detection
|
3,821
|
private void setupForwardedHeaders ( HttpAcceptSession acceptSession , HttpConnectSession connectSession ) { if ( FORWARDED_EXCLUDE . equalsIgnoreCase ( useForwarded ) ) { excludeForwardedHeaders ( connectSession ) ; return ; } if ( FORWARDED_INJECT . equalsIgnoreCase ( useForwarded ) ) { String remoteIpWithPort = format ( "%s:%d" , getResourceIpAddress ( acceptSession , FORWARDED_FOR ) , remoteClientPort ) ; if ( remoteIpWithPort != null ) { connectSession . addWriteHeader ( HEADER_X_FORWARDED_FOR , remoteIpWithPort ) ; } String serverIpAddress = getResourceIpAddress ( acceptSession , FORWARDED_BY ) ; if ( serverIpAddress != null ) { connectSession . addWriteHeader ( HEADER_X_FORWARDED_SERVER , serverIpAddress ) ; } String protocol = acceptSession . isSecure ( ) ? "https" : "http" ; connectSession . addWriteHeader ( HEADER_X_FORWARDED_PROTO , protocol ) ; String externalURI = acceptSession . getLocalAddress ( ) . getExternalURI ( ) ; String host = URIUtils . getHost ( externalURI ) ; String port = format ( "%d" , URIUtils . getPort ( externalURI ) ) ; connectSession . addWriteHeader ( HEADER_X_FORWARDED_HOST , format ( "%s:%s" , host , port ) ) ; connectSession . addWriteHeader ( HEADER_FORWARDED , format ( "%s=%s;%s=%s;%s=%s;%s=%s:%s" , FORWARDED_FOR , remoteIpWithPort , FORWARDED_BY , serverIpAddress , FORWARDED_PROTO , protocol , FORWARDED_HOST , host , port ) ) ; } }
|
Compose the Forwarded header and the X - Forwarded headers and add them to the connect session write headers .
|
3,822
|
private static void excludeForwardedHeaders ( HttpConnectSession connectSession ) { connectSession . clearWriteHeaders ( HEADER_FORWARDED ) ; connectSession . clearWriteHeaders ( HEADER_X_FORWARDED_FOR ) ; connectSession . clearWriteHeaders ( HEADER_X_FORWARDED_SERVER ) ; connectSession . clearWriteHeaders ( HEADER_X_FORWARDED_HOST ) ; connectSession . clearWriteHeaders ( HEADER_X_FORWARDED_PROTO ) ; }
|
Remove the Forwarded headers from the connect session if the use - forwarded property for the http . proxy type is set to exclude .
|
3,823
|
private static String getResourceIpAddress ( HttpAcceptSession acceptSession , String parameterName ) { String resourceIpAddress = null ; ResourceAddress resourceAddress = null ; switch ( parameterName ) { case FORWARDED_FOR : resourceAddress = acceptSession . getRemoteAddress ( ) ; break ; case FORWARDED_BY : resourceAddress = acceptSession . getLocalAddress ( ) ; break ; } ResourceAddress tcpResourceAddress = resourceAddress . findTransport ( "tcp" ) ; if ( tcpResourceAddress != null ) { URI resource = tcpResourceAddress . getResource ( ) ; resourceIpAddress = resource . getHost ( ) ; } return resourceIpAddress ; }
|
Get the IP address of the resource based on the parameter name
|
3,824
|
public NioChildDatagramChannel newChildChannel ( Channel parent , final ChannelPipeline pipeline ) { return new NioChildDatagramChannel ( parent , this , pipeline , childSink , workerPool . nextWorker ( ) , family ) ; }
|
mina . netty change - adding this to create child datagram channels
|
3,825
|
public String getMessage ( ) { String message = super . getMessage ( ) ; if ( message == null ) { message = "" ; } if ( hexdump != null ) { return message + ( message . length ( ) > 0 ? " " : "" ) + "(Hexdump: " + hexdump + ')' ; } return message ; }
|
Returns the message and the hexdump of the unknown part .
|
3,826
|
public void setUserPrincipals ( Map < String , String > userPrincipals ) { this . userPrincipals = userPrincipals ; this . serviceManagementBean . addUserPrincipals ( session , userPrincipals ) ; }
|
The following is intended to run ON the IO thread
|
3,827
|
public String getUserPrincipals ( ) { if ( userPrincipals == null ) { return null ; } JSONObject jsonObj = new JSONObject ( userPrincipals ) ; return jsonObj . toString ( ) ; }
|
In contrast to getPrincipals this is for sending a JSON value back .
|
3,828
|
public static byte [ ] getLMResponse ( String password , byte [ ] challenge ) throws Exception { byte [ ] lmHash = lmHash ( password ) ; return lmResponse ( lmHash , challenge ) ; }
|
Calculates the LM Response for the given challenge using the specified password .
|
3,829
|
public static byte [ ] getNTLMResponse ( String password , byte [ ] challenge ) throws Exception { byte [ ] ntlmHash = ntlmHash ( password ) ; return lmResponse ( ntlmHash , challenge ) ; }
|
Calculates the NTLM Response for the given challenge using the specified password .
|
3,830
|
public static byte [ ] getLMv2Response ( String target , String user , String password , byte [ ] challenge , byte [ ] clientNonce ) throws Exception { byte [ ] ntlmv2Hash = ntlmv2Hash ( target , user , password ) ; return lmv2Response ( ntlmv2Hash , clientNonce , challenge ) ; }
|
Calculates the LMv2 Response for the given challenge using the specified authentication target username password and client challenge .
|
3,831
|
public static byte [ ] getNTLM2SessionResponse ( String password , byte [ ] challenge , byte [ ] clientNonce ) throws Exception { byte [ ] ntlmHash = ntlmHash ( password ) ; MessageDigest md5 = MessageDigest . getInstance ( "MD5" ) ; md5 . update ( challenge ) ; md5 . update ( clientNonce ) ; byte [ ] sessionHash = new byte [ 8 ] ; System . arraycopy ( md5 . digest ( ) , 0 , sessionHash , 0 , 8 ) ; return lmResponse ( ntlmHash , sessionHash ) ; }
|
Calculates the NTLM2 Session Response for the given challenge using the specified password and client nonce .
|
3,832
|
private static byte [ ] createBlob ( byte [ ] targetInformation , byte [ ] clientNonce , long time ) { byte [ ] blobSignature = new byte [ ] { ( byte ) 0x01 , ( byte ) 0x01 , ( byte ) 0x00 , ( byte ) 0x00 } ; byte [ ] reserved = new byte [ ] { ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 } ; byte [ ] unknown1 = new byte [ ] { ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 } ; byte [ ] unknown2 = new byte [ ] { ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 , ( byte ) 0x00 } ; time += 11644473600000l ; time *= 10000 ; byte [ ] timestamp = new byte [ 8 ] ; for ( int i = 0 ; i < 8 ; i ++ ) { timestamp [ i ] = ( byte ) time ; time >>>= 8 ; } byte [ ] blob = new byte [ blobSignature . length + reserved . length + timestamp . length + clientNonce . length + unknown1 . length + targetInformation . length + unknown2 . length ] ; int offset = 0 ; System . arraycopy ( blobSignature , 0 , blob , offset , blobSignature . length ) ; offset += blobSignature . length ; System . arraycopy ( reserved , 0 , blob , offset , reserved . length ) ; offset += reserved . length ; System . arraycopy ( timestamp , 0 , blob , offset , timestamp . length ) ; offset += timestamp . length ; System . arraycopy ( clientNonce , 0 , blob , offset , clientNonce . length ) ; offset += clientNonce . length ; System . arraycopy ( unknown1 , 0 , blob , offset , unknown1 . length ) ; offset += unknown1 . length ; System . arraycopy ( targetInformation , 0 , blob , offset , targetInformation . length ) ; offset += targetInformation . length ; System . arraycopy ( unknown2 , 0 , blob , offset , unknown2 . length ) ; return blob ; }
|
Creates the NTLMv2 blob from the given target information block and client nonce .
|
3,833
|
public static byte [ ] hmacMD5 ( byte [ ] data , byte [ ] key ) throws Exception { byte [ ] ipad = new byte [ 64 ] ; byte [ ] opad = new byte [ 64 ] ; for ( int i = 0 ; i < 64 ; i ++ ) { if ( i < key . length ) { ipad [ i ] = ( byte ) ( key [ i ] ^ 0x36 ) ; opad [ i ] = ( byte ) ( key [ i ] ^ 0x5c ) ; } else { ipad [ i ] = 0x36 ; opad [ i ] = 0x5c ; } } byte [ ] content = new byte [ data . length + 64 ] ; System . arraycopy ( ipad , 0 , content , 0 , 64 ) ; System . arraycopy ( data , 0 , content , 64 , data . length ) ; MessageDigest md5 = MessageDigest . getInstance ( "MD5" ) ; data = md5 . digest ( content ) ; content = new byte [ data . length + 64 ] ; System . arraycopy ( opad , 0 , content , 0 , 64 ) ; System . arraycopy ( data , 0 , content , 64 , data . length ) ; return md5 . digest ( content ) ; }
|
Calculates the HMAC - MD5 hash of the given data using the specified hashing key .
|
3,834
|
private static void oddParity ( byte [ ] bytes ) { for ( int i = 0 ; i < bytes . length ; i ++ ) { byte b = bytes [ i ] ; boolean needsParity = ( ( ( b >>> 7 ) ^ ( b >>> 6 ) ^ ( b >>> 5 ) ^ ( b >>> 4 ) ^ ( b >>> 3 ) ^ ( b >>> 2 ) ^ ( b >>> 1 ) ) & 0x01 ) == 0 ; if ( needsParity ) { bytes [ i ] |= ( byte ) 0x01 ; } else { bytes [ i ] &= ( byte ) 0xfe ; } } }
|
Applies odd parity to the given byte array .
|
3,835
|
public Map < String , Map < String , String > > getLoggedInSessions ( ) { Map < Long , Map < String , String > > sessionPrincipalMap = serviceManagementBean . getLoggedInSessions ( ) ; Map < String , Map < String , String > > result = new HashMap < > ( ) ; for ( Map . Entry < Long , Map < String , String > > entry : sessionPrincipalMap . entrySet ( ) ) { long sessionId = entry . getKey ( ) ; Map < String , String > userPrincipals = entry . getValue ( ) ; ObjectName sessionMBeanName = managementServiceHandler . getSessionMXBean ( sessionId ) . getObjectName ( ) ; result . put ( sessionMBeanName . toString ( ) , userPrincipals ) ; } return result ; }
|
Return a map of session mbean names to the user principals for those sessions . The serviceManagementBean stores them as session ID to user principals and we have to convert the session ID to mbean name here . Gross but it s the only way to not have JMX - specific stuff in the ServiceManagementBean .
|
3,836
|
public void cancel ( ScheduledFuture < ? > scheduledFuture ) { clear ( ) ; if ( scheduledFuture != null && ! scheduledFuture . isDone ( ) ) { scheduledFuture . cancel ( false ) ; } }
|
Cancel the scheduled command .
|
3,837
|
public ScheduledFuture < ? > schedule ( ScheduledExecutorService scheduler , long delay , final TimeUnit unit ) { return scheduler . schedule ( this , delay , unit ) ; }
|
Schedule this command using the scheduler delay and time units provided .
|
3,838
|
public void sessionOpened ( IoSession session ) { session . getConfig ( ) . setWriteTimeout ( writeTimeout ) ; session . getConfig ( ) . setIdleTime ( IdleStatus . READER_IDLE , readTimeout ) ; InputStream in = new IoSessionInputStream ( ) ; OutputStream out = new IoSessionOutputStream ( session ) ; session . setAttribute ( KEY_IN , in ) ; session . setAttribute ( KEY_OUT , out ) ; processStreamIo ( session , in , out ) ; }
|
Initializes streams and timeout settings .
|
3,839
|
public void messageReceived ( IoSession session , Object buf ) { final IoSessionInputStream in = ( IoSessionInputStream ) session . getAttribute ( KEY_IN ) ; in . write ( ( IoBuffer ) buf ) ; }
|
Forwards read data to input stream .
|
3,840
|
public void exceptionCaught ( IoSession session , Throwable cause ) { final IoSessionInputStream in = ( IoSessionInputStream ) session . getAttribute ( KEY_IN ) ; IOException e = null ; if ( cause instanceof StreamIoException ) { e = ( IOException ) cause . getCause ( ) ; } else if ( cause instanceof IOException ) { e = ( IOException ) cause ; } if ( e != null && in != null ) { in . throwException ( e ) ; } else { LOGGER . warn ( "Unexpected exception." , cause ) ; session . close ( true ) ; } }
|
Forwards caught exceptions to input stream .
|
3,841
|
public void sessionIdle ( IoSession session , IdleStatus status ) { if ( status == IdleStatus . READER_IDLE ) { throw new StreamIoException ( new SocketTimeoutException ( "Read timeout" ) ) ; } }
|
Handles read timeout .
|
3,842
|
public void messageReceived ( final NextFilter nextFilter , final IoBuffer buf ) { try { if ( buf . remaining ( ) >= SocksProxyConstants . SOCKS_4_RESPONSE_SIZE ) { handleResponse ( buf ) ; } } catch ( Exception ex ) { closeSession ( "Proxy handshake failed: " , ex ) ; } }
|
Handle incoming data during the handshake process . Should consume only the handshake data from the buffer leaving any extra data in place .
|
3,843
|
public void findDuplicateJars ( ) throws IOException , DuplicateJarsException { Map < String , List < String > > artifactsToVersion = new HashMap < > ( ) ; Enumeration < URL > manifestURLs = classPathParser . getManifestURLs ( ) ; while ( manifestURLs . hasMoreElements ( ) ) { parseManifestFileFromClassPathEntry ( manifestURLs . nextElement ( ) , artifactsToVersion ) ; } checkForDuplicateJars ( artifactsToVersion ) ; }
|
Parses the class path system attribute and the manifest files and if there are duplicate jar a DuplicateJarsException is thrown .
|
3,844
|
public ChannelFuture bindAsync ( final SocketAddress localAddress ) { if ( localAddress == null ) { throw new NullPointerException ( "localAddress" ) ; } ChannelPipeline pipeline ; try { pipeline = getPipelineFactory ( ) . getPipeline ( ) ; } catch ( Exception e ) { throw new ChannelPipelineException ( "Failed to initialize a pipeline." , e ) ; } Channel ch = getFactory ( ) . newChannel ( pipeline ) ; boolean success = false ; try { ch . getConfig ( ) . setOptions ( getOptions ( ) ) ; success = true ; } finally { if ( ! success ) { ch . close ( ) ; } } ChannelFuture future = ch . bind ( localAddress ) ; return future ; }
|
Creates a new channel which is bound to the specified local address .
|
3,845
|
public void setProperties ( Properties properties ) { if ( this . env == null ) { this . env = properties ; } else { this . env . putAll ( properties ) ; } if ( baseGateway != null ) { baseGateway . setProperties ( properties ) ; } }
|
Configure a new Gateway instance with the given environment properties .
|
3,846
|
public Attributes getManifestAttributesFromURL ( URL url ) throws IOException { Manifest manifest = new Manifest ( url . openStream ( ) ) ; return manifest . getMainAttributes ( ) ; }
|
Retrieves the jar file manifest attributes for a given class path entry
|
3,847
|
private int processConnections ( Iterator < H > handlers ) { int nHandles = 0 ; while ( handlers . hasNext ( ) ) { H handle = handlers . next ( ) ; handlers . remove ( ) ; ConnectionRequest connectionRequest = getConnectionRequest ( handle ) ; if ( connectionRequest == null ) { continue ; } boolean success = false ; try { if ( finishConnect ( handle ) ) { T session = newSession ( processor , handle ) ; initSession ( session , connectionRequest , connectionRequest . getSessionInitializer ( ) ) ; session . getProcessor ( ) . add ( session ) ; nHandles ++ ; } success = true ; } catch ( Throwable e ) { connectionRequest . setException ( e ) ; } finally { if ( ! success ) { cancelQueue . offer ( connectionRequest ) ; } } } return nHandles ; }
|
Process the incoming connections creating a new session for each valid connection .
|
3,848
|
private boolean checkLongPollingOrder ( HttpAcceptSession session ) { if ( firstWriter && ! validateSequenceNo && longpoll ( session ) ) { String message = "Out of order long-polling request, must not be first" ; setCloseException ( new IOException ( message ) ) ; HttpStatus status = HttpStatus . CLIENT_BAD_REQUEST ; session . setStatus ( status ) ; session . setWriteHeader ( HEADER_CONTENT_LENGTH , "0" ) ; session . close ( true ) ; return false ; } return true ; }
|
If the first write request is long - polling then it is out of order
|
3,849
|
private void addConnectFuture ( ConnectFuture future ) { Object key = connectFutures . add ( future ) ; future . getSession ( ) . setAttributeIfAbsent ( CONNECT_FUTURE_KEY , key ) ; }
|
the associated ConnectFuture from the map of preconnect futures .
|
3,850
|
public byte [ ] getPort ( ) { byte [ ] port = new byte [ 2 ] ; int p = ( getEndpointAddress ( ) == null ? this . port : getEndpointAddress ( ) . getPort ( ) ) ; port [ 1 ] = ( byte ) p ; port [ 0 ] = ( byte ) ( p >> 8 ) ; return port ; }
|
Return the server port as a byte array .
|
3,851
|
public synchronized final String getHost ( ) { if ( host == null ) { InetSocketAddress adr = getEndpointAddress ( ) ; if ( adr != null && ! adr . isUnresolved ( ) ) { host = getEndpointAddress ( ) . getHostName ( ) ; } } return host ; }
|
Return the server host name .
|
3,852
|
public List < WebSocketExtension > offerWebSocketExtensions ( WsResourceAddress address , ExtensionHelper extensionHelper ) { List < WebSocketExtension > list = new ArrayList < > ( ) ; for ( WebSocketExtensionFactorySpi factory : factoriesRO . values ( ) ) { WebSocketExtension extension = factory . offer ( extensionHelper , address ) ; if ( extension != null ) { list . add ( extension ) ; } } return list ; }
|
Returns a list of extensions that want to be part of websocket request
|
3,853
|
private DefaultServiceDefaultsContext resolveServiceDefaults ( ServiceDefaultsType serviceDefaults , RealmsContext realmsContext ) { if ( serviceDefaults == null ) { return null ; } DefaultAcceptOptionsContext acceptOptions = null ; ServiceAcceptOptionsType serviceAcceptOptions = serviceDefaults . getAcceptOptions ( ) ; if ( serviceAcceptOptions != null ) { acceptOptions = new DefaultAcceptOptionsContext ( null , serviceAcceptOptions ) ; } DefaultConnectOptionsContext connectOptions = null ; ServiceConnectOptionsType serviceConnectOptions = serviceDefaults . getConnectOptions ( ) ; if ( serviceConnectOptions != null ) { connectOptions = new DefaultConnectOptionsContext ( null , serviceConnectOptions ) ; } Map < String , String > mimeMappings = null ; MimeMappingType [ ] mimeMappingTypes = serviceDefaults . getMimeMappingArray ( ) ; if ( mimeMappingTypes != null ) { mimeMappings = new HashMap < > ( ) ; for ( MimeMappingType mmt : mimeMappingTypes ) { mimeMappings . put ( mmt . getExtension ( ) , mmt . getMimeType ( ) ) ; } } return new DefaultServiceDefaultsContext ( acceptOptions , connectOptions , mimeMappings ) ; }
|
own object to management .
|
3,854
|
private boolean supportsConnects ( String serviceType ) { return ! serviceType . equals ( "jms" ) && ! serviceType . equals ( "echo" ) && ! serviceType . equals ( "management.jmx" ) && ! serviceType . equals ( "$management.jmx$" ) && ! serviceType . equals ( "management.snmp" ) && ! serviceType . equals ( "$management.snmp$" ) && ! serviceType . equals ( "directory" ) ; }
|
Gross method to tell us if a given service type supports using connect s . XXX This needs to be fixed later!
|
3,855
|
protected final void removeFilter ( IoFilterChain filterChain , IoFilter filter ) { if ( filterChain . contains ( filter ) ) { filterChain . remove ( filter ) ; } }
|
A utility method to remove a filter from a filter chain without complaining if it is not in the chain .
|
3,856
|
public void sessionClosed ( NextFilter nextFilter , IoSession session ) throws SSLException { SslHandler handler = getSslSessionHandler ( session ) ; try { synchronized ( handler ) { handler . destroy ( ) ; } handler . flushScheduledEvents ( ) ; } finally { nextFilter . sessionClosed ( session ) ; } }
|
IoFilter impl .
|
3,857
|
private boolean await0 ( long timeoutMillis , boolean interruptable ) throws InterruptedException { long endTime = System . currentTimeMillis ( ) + timeoutMillis ; if ( endTime < 0 ) { endTime = Long . MAX_VALUE ; } synchronized ( lock ) { if ( ready ) { return ready ; } else if ( timeoutMillis <= 0 ) { return ready ; } waiters ++ ; try { for ( ; ; ) { try { long timeOut = Math . min ( timeoutMillis , DEAD_LOCK_CHECK_INTERVAL ) ; lock . wait ( timeOut ) ; } catch ( InterruptedException e ) { if ( interruptable ) { throw e ; } } if ( ready ) { return true ; } if ( endTime < System . currentTimeMillis ( ) ) { return ready ; } } } finally { waiters -- ; if ( ! ready ) { checkDeadLock ( ) ; } } } }
|
Wait for the Future to be ready . If the requested delay is 0 or negative this method immediately returns the value of the ready flag . Every 5 second the wait will be suspended to be able to check if there is a deadlock or not .
|
3,858
|
public void setValue ( Object newValue ) { synchronized ( lock ) { if ( ready ) { return ; } result = newValue ; ready = true ; if ( waiters > 0 ) { lock . notifyAll ( ) ; } } notifyListeners ( ) ; }
|
Sets the result of the asynchronous operation and mark it as finished .
|
3,859
|
public void destroy ( ) { if ( sslEngine == null ) { return ; } try { sslEngine . closeInbound ( ) ; } catch ( SSLException e ) { LOGGER . debug ( "Unexpected exception from SSLEngine.closeInbound()." , e ) ; } if ( outNetBuffer != null ) { outNetBuffer . capacity ( sslEngine . getSession ( ) . getPacketBufferSize ( ) ) ; } else { createOutNetBuffer ( 0 ) ; } try { do { outNetBuffer . clear ( ) ; } while ( sslEngine . wrap ( emptyBuffer . buf ( ) , outNetBuffer . buf ( ) ) . bytesProduced ( ) > 0 ) ; } catch ( SSLException e ) { } finally { destroyOutNetBuffer ( ) ; } sslEngine . closeOutbound ( ) ; sslEngine = null ; preHandshakeEventQueue . clear ( ) ; }
|
Release allocated buffers .
|
3,860
|
public boolean closeOutbound ( ) throws SSLException { if ( sslEngine == null || sslEngine . isOutboundDone ( ) ) { return false ; } sslEngine . closeOutbound ( ) ; createOutNetBuffer ( 0 ) ; SSLEngineResult result ; for ( ; ; ) { result = sslEngine . wrap ( emptyBuffer . buf ( ) , outNetBuffer . buf ( ) ) ; if ( result . getStatus ( ) == SSLEngineResult . Status . BUFFER_OVERFLOW ) { outNetBuffer . capacity ( outNetBuffer . capacity ( ) << 1 ) ; outNetBuffer . limit ( outNetBuffer . capacity ( ) ) ; } else { break ; } } if ( result . getStatus ( ) != SSLEngineResult . Status . CLOSED ) { throw new SSLException ( "Improper close state: " + result ) ; } outNetBuffer . flip ( ) ; return true ; }
|
Start SSL shutdown process .
|
3,861
|
public static Collection < InetAddress > getAllByName ( String host , boolean allowIPv6 ) { Enumeration < NetworkInterface > networkInterfaces = cloneInterfaces ( ResolutionUtils . networkInterfaces ) ; List < String > resolvedAddresses = resolveDeviceAddress ( host , networkInterfaces , allowIPv6 ) ; List < InetAddress > resolvedDeviceURIs = new ArrayList < > ( ) ; List < InetAddress > resolvedHosts = resolvedDeviceURIs ; for ( String resolvedAddress : resolvedAddresses ) { try { resolvedHosts . addAll ( asList ( InetAddress . getAllByName ( resolvedAddress ) ) ) ; } catch ( UnknownHostException e ) { e . printStackTrace ( ) ; } } return resolvedHosts ; }
|
Method resolving host to InetAddresses
|
3,862
|
public static InetSocketAddress parseBindAddress ( String bindAddress ) { Exception cause = null ; try { if ( ! bindAddress . contains ( ":" ) ) { return new InetSocketAddress ( Integer . parseInt ( bindAddress ) ) ; } Pattern pattern = Pattern . compile ( URIUtils . NETWORK_INTERFACE_AUTHORITY_PORT ) ; Matcher matcher = pattern . matcher ( bindAddress ) ; if ( matcher . find ( ) ) { return new InetSocketAddress ( matcher . group ( 1 ) , parseInt ( matcher . group ( 2 ) ) ) ; } String tmpAddress = "scheme://" + bindAddress ; URI uri = URI . create ( tmpAddress ) ; if ( uri . getPort ( ) != - 1 ) { return new InetSocketAddress ( uri . getHost ( ) , uri . getPort ( ) ) ; } } catch ( Exception e ) { cause = e ; } throw new IllegalArgumentException ( String . format ( "Bind address \"%s\" should be in " + "\"host/ipv4:port\", \"[ipv6]:port\", \"@network_interface:port\", \"[@network interface]:port\" or \"port\" " + "format." , bindAddress ) , cause ) ; }
|
Method creating an InetAddress from String .
|
3,863
|
private static List < String > resolveDeviceAddress ( String deviceName , Enumeration < NetworkInterface > networkInterfaces , boolean allowIPv6 ) { List < String > resolvedAddresses = new ArrayList < > ( ) ; if ( deviceName . startsWith ( "[@" ) && deviceName . endsWith ( "]" ) ) { deviceName = deviceName . substring ( 2 , deviceName . lastIndexOf ( ']' ) ) ; } else if ( deviceName . startsWith ( "@" ) ) { deviceName = deviceName . substring ( 1 ) ; } while ( networkInterfaces . hasMoreElements ( ) ) { NetworkInterface networkInterface = networkInterfaces . nextElement ( ) ; if ( deviceName . toLowerCase ( ) . equals ( networkInterface . getDisplayName ( ) . toLowerCase ( ) ) ) { Enumeration < InetAddress > inetAddresses = networkInterface . getInetAddresses ( ) ; while ( inetAddresses . hasMoreElements ( ) ) { InetAddress inetAddress = inetAddresses . nextElement ( ) ; if ( inetAddress instanceof Inet6Address ) { if ( ! allowIPv6 ) { continue ; } String inet6HostAddress = inetAddress . getHostAddress ( ) ; resolvedAddresses . add ( String . format ( "[%s]" , inet6HostAddress ) ) ; } else { resolvedAddresses . add ( inetAddress . getHostAddress ( ) ) ; } } } Enumeration < NetworkInterface > subInterfaces = networkInterface . getSubInterfaces ( ) ; if ( subInterfaces . hasMoreElements ( ) ) { resolvedAddresses . addAll ( resolveDeviceAddress ( deviceName , subInterfaces , allowIPv6 ) ) ; } } return resolvedAddresses ; }
|
Method performing device address resolution
|
3,864
|
protected ByteBuffer calculatePrefixBytes ( int payloadLength , byte opCode ) { int totalOffset = 2 + WsUtils . calculateEncodedLengthSize ( payloadLength ) ; ByteBuffer binary = ByteBuffer . allocate ( totalOffset ) ; binary . put ( opCode ) ; WsUtils . encodeLength ( binary , payloadLength ) ; switch ( binary . get ( binary . position ( ) - 1 ) ) { case 0x00 : binary . put ( binary . position ( ) - 1 , ( byte ) 0x7f ) ; binary . put ( ( byte ) 0x30 ) ; break ; case 0x0a : binary . put ( binary . position ( ) - 1 , ( byte ) 0x7f ) ; binary . put ( ( byte ) 0x6e ) ; break ; case 0x0d : binary . put ( binary . position ( ) - 1 , ( byte ) 0x7f ) ; binary . put ( ( byte ) 0x72 ) ; break ; case 0x7f : binary . put ( binary . position ( ) - 1 , ( byte ) 0x7f ) ; binary . put ( ( byte ) 0x7f ) ; break ; } binary . flip ( ) ; return binary ; }
|
quick calculate WsebFrame prefix bytes
|
3,865
|
private byte [ ] doEscapeZeroAndNewline ( byte [ ] decodedArray , int decodedArrayOffset , int decodedArrayPosition , int decodedArrayLimit , byte [ ] encodedArray , int [ ] encodedArrayInsertionCount , ByteBuffer prefix ) { int prefixLength = prefix . remaining ( ) ; for ( ; decodedArrayPosition < decodedArrayLimit ; decodedArrayPosition ++ ) { byte decodedValue = decodedArray [ decodedArrayPosition ] ; switch ( decodedValue ) { case 0x00 : encodedArray = supplyEncodedArray ( decodedArray , decodedArrayOffset , decodedArrayPosition , decodedArrayLimit , encodedArray , encodedArrayInsertionCount , prefix ) ; encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = 0x7f ; encodedArrayInsertionCount [ 0 ] ++ ; encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = 0x30 ; continue ; case 0x0a : encodedArray = supplyEncodedArray ( decodedArray , decodedArrayOffset , decodedArrayPosition , decodedArrayLimit , encodedArray , encodedArrayInsertionCount , prefix ) ; encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = 0x7f ; encodedArrayInsertionCount [ 0 ] ++ ; encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = 0x6e ; continue ; case 0x0d : encodedArray = supplyEncodedArray ( decodedArray , decodedArrayOffset , decodedArrayPosition , decodedArrayLimit , encodedArray , encodedArrayInsertionCount , prefix ) ; encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = 0x7f ; encodedArrayInsertionCount [ 0 ] ++ ; encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = 0x72 ; continue ; case 0x7f : encodedArray = supplyEncodedArray ( decodedArray , decodedArrayOffset , decodedArrayPosition , decodedArrayLimit , encodedArray , encodedArrayInsertionCount , prefix ) ; encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = 0x7f ; encodedArrayInsertionCount [ 0 ] ++ ; encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = 0x7f ; continue ; default : if ( encodedArray != null ) { encodedArray [ decodedArrayPosition + encodedArrayInsertionCount [ 0 ] + prefixLength ] = decodedValue ; } continue ; } } return encodedArray ; }
|
insert escape characters into encodedArray return number of inserted bytes
|
3,866
|
public void setAttributes ( Map < String , ? > attributes ) { if ( attributes == null ) { attributes = new HashMap < > ( ) ; } this . attributes . clear ( ) ; this . attributes . putAll ( attributes ) ; }
|
Sets the attribute map . The specified attributes are copied into the underlying map so modifying the specified attributes parameter after the call won t change the internal state .
|
3,867
|
public void sessionCreated ( NextFilter nextFilter , IoSession session ) throws Exception { for ( Map . Entry < String , Object > e : attributes . entrySet ( ) ) { session . setAttribute ( e . getKey ( ) , e . getValue ( ) ) ; } nextFilter . sessionCreated ( session ) ; }
|
Puts all pre - configured attributes into the actual session attribute map and forward the event to the next filter .
|
3,868
|
public long getTotalTime ( IoEventType type ) { switch ( type ) { case MESSAGE_RECEIVED : if ( profileMessageReceived ) { return messageReceivedTimerWorker . getTotal ( ) ; } break ; case MESSAGE_SENT : if ( profileMessageSent ) { return messageSentTimerWorker . getTotal ( ) ; } break ; case SESSION_CREATED : if ( profileSessionCreated ) { return sessionCreatedTimerWorker . getTotal ( ) ; } break ; case SESSION_OPENED : if ( profileSessionOpened ) { return sessionOpenedTimerWorker . getTotal ( ) ; } break ; case SESSION_IDLE : if ( profileSessionIdle ) { return sessionIdleTimerWorker . getTotal ( ) ; } break ; case SESSION_CLOSED : if ( profileSessionClosed ) { return sessionClosedTimerWorker . getTotal ( ) ; } break ; } throw new IllegalArgumentException ( "You are not monitoring this event. Please add this event first." ) ; }
|
The total time this method has been executing
|
3,869
|
protected WriteFuture writeData ( final NextFilter nextFilter , final IoBuffer data ) { ProxyHandshakeIoBuffer writeBuffer = new ProxyHandshakeIoBuffer ( data ) ; LOGGER . debug ( " session write: {}" , writeBuffer ) ; WriteFuture writeFuture = new DefaultWriteFuture ( getSession ( ) ) ; getProxyFilter ( ) . writeData ( nextFilter , getSession ( ) , new DefaultWriteRequest ( writeBuffer , writeFuture ) , true ) ; return writeFuture ; }
|
Writes data to the proxy server .
|
3,870
|
protected final void setHandshakeComplete ( ) { synchronized ( this ) { handshakeComplete = true ; } ProxyIoSession proxyIoSession = getProxyIoSession ( ) ; proxyIoSession . getConnector ( ) . fireConnected ( proxyIoSession . getSession ( ) ) . awaitUninterruptibly ( ) ; LOGGER . debug ( " handshake completed" ) ; try { proxyIoSession . getEventQueue ( ) . flushPendingSessionEvents ( ) ; flushPendingWriteRequests ( ) ; } catch ( Exception ex ) { LOGGER . error ( "Unable to flush pending write requests" , ex ) ; } }
|
Signals that the handshake has finished .
|
3,871
|
protected synchronized void flushPendingWriteRequests ( ) throws Exception { LOGGER . debug ( " flushPendingWriteRequests()" ) ; if ( writeRequestQueue == null ) { return ; } Event scheduledWrite ; while ( ( scheduledWrite = writeRequestQueue . poll ( ) ) != null ) { LOGGER . debug ( " Flushing buffered write request: {}" , scheduledWrite . data ) ; getProxyFilter ( ) . filterWrite ( scheduledWrite . nextFilter , getSession ( ) , ( WriteRequest ) scheduledWrite . data ) ; } writeRequestQueue = null ; }
|
Send any write requests which were queued whilst waiting for handshaking to complete .
|
3,872
|
public synchronized void enqueueWriteRequest ( final NextFilter nextFilter , final WriteRequest writeRequest ) { if ( writeRequestQueue == null ) { writeRequestQueue = new LinkedList < > ( ) ; } writeRequestQueue . offer ( new Event ( nextFilter , writeRequest ) ) ; }
|
Enqueue a message to be written once handshaking is complete .
|
3,873
|
public void doMessageReceived ( NextFilter nextFilter , IoSession session , Object message ) throws Exception { if ( ! httpRequestMessageReceived ( nextFilter , session , message ) ) return ; HttpRequestMessage httpRequest = ( HttpRequestMessage ) message ; if ( httpRequest . getSubject ( ) == null ) { httpRequest . setSubject ( ( ( IoSessionEx ) session ) . getSubject ( ) ) ; } ResourceAddress httpAddress = httpRequest . getLocalAddress ( ) ; HttpRealmInfo [ ] realms = httpAddress . getOption ( HttpResourceAddress . REALMS ) ; if ( realms . length == 0 ) { ResultAwareLoginContext loginContext = null ; if ( session instanceof DefaultHttpSession ) { loginContext = ( ( DefaultHttpSession ) session ) . getLoginContext ( ) ; } if ( loginContext != null ) { httpRequest . setLoginContext ( loginContext ) ; } else { setUnprotectedLoginContext ( httpRequest ) ; } final boolean loggerIsEnabled = logger != null && logger . isTraceEnabled ( ) ; if ( loggerIsEnabled ) { logger . trace ( "HttpSubjectSecurityFilter skipped because no realm is configured." ) ; } super . doMessageReceived ( nextFilter , session , message ) ; return ; } securityMessageReceived ( nextFilter , session , httpRequest ) ; }
|
Security code for subject - security LEGACY
|
3,874
|
void securityMessageReceived ( NextFilter nextFilter , IoSession session , Object message ) throws Exception { final boolean loggerIsEnabled = logger != null && logger . isTraceEnabled ( ) ; if ( ! httpRequestMessageReceived ( nextFilter , session , message ) ) return ; HttpRequestMessage httpRequest = ( HttpRequestMessage ) message ; ResourceAddress httpAddress = httpRequest . getLocalAddress ( ) ; if ( alreadyLoggedIn ( httpRequest ) ) { if ( httpRequest . getLoginContext ( ) == null ) { setUnprotectedLoginContext ( httpRequest ) ; } if ( loggerIsEnabled ) { logger . trace ( "HttpSubjectSecurityFilter skipped because we are already allowed or logged in." ) ; } super . doMessageReceived ( nextFilter , session , message ) ; return ; } HttpRealmInfo [ ] realms = httpAddress . getOption ( HttpResourceAddress . REALMS ) ; if ( realms . length == 0 ) { setUnprotectedLoginContext ( httpRequest ) ; if ( loggerIsEnabled ) { logger . trace ( "HttpSecurityStandardFilter skipped because no realm is configured." ) ; } super . doMessageReceived ( nextFilter , session , message ) ; return ; } String challengeIdentity = httpRequest . getHeader ( HEADER_SEC_CHALLENGE_IDENTITY ) ; LoginContext [ ] loginContexts = getLoginContexts ( challengeIdentity ) ; int realmIndex = findCurrentRealm ( loginContexts ) ; HttpRealmInfo realm = realms [ realmIndex ] ; AuthenticationTokenExtractor tokenExtractor = DefaultAuthenticationTokenExtractor . INSTANCE ; DefaultAuthenticationToken authToken = ( DefaultAuthenticationToken ) tokenExtractor . extract ( httpRequest , realm ) ; String expectedChallengeScheme = getBaseAuthScheme ( realm . getChallengeScheme ( ) ) ; if ( authToken . getScheme ( ) == null ) { authToken . setScheme ( expectedChallengeScheme ) ; } suspendIncoming ( session ) ; TypedCallbackHandlerMap additionalCallbacks = null ; if ( realmIndex > 0 ) { additionalCallbacks = new TypedCallbackHandlerMap ( ) ; Function < String , Subject > subjects = name -> findNamedSubject ( name , realms , realmIndex , loginContexts ) ; NamedSubjectCallbackHandler callbackHandler = new NamedSubjectCallbackHandler ( subjects ) ; additionalCallbacks . put ( NamedSubjectCallback . class , callbackHandler ) ; } LoginContextTask loginContextTask = new LoginContextTask ( nextFilter , session , httpRequest , authToken , additionalCallbacks , realms , realmIndex , loginContexts ) ; scheduler . execute ( loginContextTask ) ; }
|
Security code for subject - security going forward
|
3,875
|
private void writeRequest0 ( final NextFilter nextFilter , final HttpProxyRequest request ) { try { String data = request . toHttpString ( ) ; IoBuffer buf = IoBuffer . wrap ( data . getBytes ( getProxyIoSession ( ) . getCharsetName ( ) ) ) ; LOGGER . debug ( " write:\n{}" , data . replace ( "\r" , "\\r" ) . replace ( "\n" , "\\n\n" ) ) ; writeData ( nextFilter , buf ) ; } catch ( UnsupportedEncodingException ex ) { closeSession ( "Unable to send HTTP request: " , ex ) ; } }
|
Encodes a HTTP request and sends it to the proxy server .
|
3,876
|
private void reconnect ( final NextFilter nextFilter , final HttpProxyRequest request ) { LOGGER . debug ( "Reconnecting to proxy ..." ) ; final ProxyIoSession proxyIoSession = getProxyIoSession ( ) ; proxyIoSession . getConnector ( ) . connect ( new IoSessionInitializer < ConnectFuture > ( ) { public void initializeSession ( final IoSession session , ConnectFuture future ) { LOGGER . debug ( "Initializing new session: {}" , session ) ; session . setAttribute ( ProxyIoSession . PROXY_SESSION , proxyIoSession ) ; proxyIoSession . setSession ( session ) ; LOGGER . debug ( " setting up proxyIoSession: {}" , proxyIoSession ) ; future . addListener ( new IoFutureListener < ConnectFuture > ( ) { public void operationComplete ( ConnectFuture future ) { proxyIoSession . setReconnectionNeeded ( false ) ; writeRequest0 ( nextFilter , request ) ; } } ) ; } } ) ; }
|
Method to reconnect to the proxy when it decides not to maintain the connection during handshake .
|
3,877
|
protected HttpProxyResponse decodeResponse ( final String response ) throws Exception { LOGGER . debug ( " parseResponse()" ) ; String [ ] responseLines = response . split ( HttpProxyConstants . CRLF ) ; String [ ] statusLine = responseLines [ 0 ] . trim ( ) . split ( " " , 2 ) ; if ( statusLine . length < 2 ) { throw new Exception ( "Invalid response status line (" + statusLine + "). Response: " + response ) ; } if ( statusLine [ 1 ] . matches ( "^\\d\\d\\d" ) ) { throw new Exception ( "Invalid response code (" + statusLine [ 1 ] + "). Response: " + response ) ; } Map < String , List < String > > headers = new HashMap < > ( ) ; for ( int i = 1 ; i < responseLines . length ; i ++ ) { String [ ] args = responseLines [ i ] . split ( ":\\s?" , 2 ) ; StringUtilities . addValueToHeader ( headers , args [ 0 ] , args [ 1 ] , false ) ; } return new HttpProxyResponse ( statusLine [ 0 ] , statusLine [ 1 ] , headers ) ; }
|
Parse a HTTP response from the proxy server .
|
3,878
|
public static void assertIOThread ( Thread t , boolean flag ) { if ( flag ) { assert t . equals ( Thread . currentThread ( ) ) : "Management NOT on IO thread when expected" ; } else { assert ! ( t . equals ( Thread . currentThread ( ) ) ) : "Management on IO thread when not expected" ; } }
|
means we expect that we are NOT .
|
3,879
|
public static long sumFutures ( List < Future < Object > > futures ) { long total = 0 ; for ( Future < Object > f : futures ) { try { total += ( Long ) f . get ( ) ; } catch ( Exception ignore ) { System . out . println ( "### sumFutures got exception!" ) ; } } return total ; }
|
This must NOT run on any IO worker thread
|
3,880
|
public static String makeJSONArrayString ( Object [ ] values ) { StringBuilder buf = new StringBuilder ( ) ; int numVals = values . length ; buf . append ( "[" ) ; for ( int i = 0 ; i < numVals ; i ++ ) { buf . append ( QUOTE ) ; buf . append ( values [ i ] . toString ( ) ) ; buf . append ( QUOTE ) ; if ( i < numVals - 1 ) { buf . append ( COMMA ) ; } } buf . append ( "]" ) ; return buf . toString ( ) ; }
|
Given an array of strings return a string that equals the output of creating a JSONArray and then stringifying it .
|
3,881
|
public void flushTo ( int index ) { ByteArray removed = cba . removeTo ( index ) ; flusher . flush ( removed ) ; }
|
Flush to the given index .
|
3,882
|
public void messageReceived ( AbstractNioChannel < ? > channel , ChannelEvent event ) { boolean written = readQueue . offer ( event ) ; if ( ! written ) { noDroppedMessages ++ ; if ( noDroppedMessages % 10000 == 0 ) { if ( LOGGER . isInfoEnabled ( ) ) { String msg = "UDP read queue full, dropping messages, consider increasing udp read queue size " + "using system property " + UDP_CHANNEL_READ_QUEUE_SIZE . getPropertyName ( ) ; LOGGER . info ( msg ) ; } } } if ( selector != null ) { if ( wakenUp . compareAndSet ( false , true ) ) { selector . wakeup ( ) ; } } }
|
This method is called from the boss thread
|
3,883
|
public static GatewayVersion parseGatewayVersion ( String version ) throws Exception { if ( "develop-SNAPSHOT" . equals ( version ) ) { return new GatewayVersion ( 0 , 0 , 0 ) ; } else { String regex = "(?<major>[0-9]+)\\.(?<minor>[0-9]+)\\.(?<patch>[0-9]+)-?(?<rc>[RC0-9{3}]*)" ; Pattern pattern = Pattern . compile ( regex ) ; Matcher matcher = pattern . matcher ( version ) ; if ( matcher . matches ( ) ) { int major = Integer . parseInt ( matcher . group ( "major" ) ) ; int minor = Integer . parseInt ( matcher . group ( "minor" ) ) ; int patch = Integer . parseInt ( matcher . group ( "patch" ) ) ; String rc = matcher . group ( "rc" ) ; return new GatewayVersion ( major , minor , patch , rc ) ; } else { throw new IllegalArgumentException ( String . format ( "version String is not of form %s" , regex ) ) ; } } }
|
Parses a GatewayVersion from a String
|
3,884
|
public void start ( ) { IoFutureListener < ConnectFuture > tmpConnectListener ; if ( interval > 0 ) { tmpConnectListener = new IoFutureListener < ConnectFuture > ( ) { public void operationComplete ( ConnectFuture future ) { heartbeatFilter . setServiceConnected ( future . isConnected ( ) ) ; updateConnectTimes ( future . isConnected ( ) ) ; } } ; } else { tmpConnectListener = new IoFutureListener < ConnectFuture > ( ) { public void operationComplete ( ConnectFuture future ) { updateConnectTimes ( future . isConnected ( ) ) ; } } ; } final IoFutureListener < ConnectFuture > connectListener = tmpConnectListener ; Worker [ ] workers = tcpAcceptor . getWorkers ( ) ; assert preparedConnectionCount == 0 || preparedConnectionCount >= workers . length : "Prepared connection count must be 0, or >= number of IO threads" ; int minCountPerThread = preparedConnectionCount / workers . length ; int remainder = preparedConnectionCount % workers . length ; for ( Worker worker : workers ) { final int count = remainder -- > 0 ? minCountPerThread + 1 : minCountPerThread ; Runnable startConnectionPoolTask = ( ) -> { ConnectionPool currentPool = connectionPool . get ( ) ; if ( currentPool == null ) { currentPool = new ConnectionPool ( serviceCtx , connectHandler , connectURI , heartbeatFilter , connectListener , count , true ) ; connectionPool . set ( currentPool ) ; } currentPool . start ( ) ; } ; worker . executeInIoThread ( startConnectionPoolTask ) ; } }
|
Start the connection manager so that any pre - connections are established .
|
3,885
|
public static void resolveConflicts ( PatternCacheControl specificPattern , PatternCacheControl generalPattern ) { for ( Entry < Directive , String > entry : generalPattern . getDirectives ( ) . entrySet ( ) ) { Directive generalDirective = entry . getKey ( ) ; String generalValue = entry . getValue ( ) ; if ( generalValue == EMPTY_STRING_VALUE ) { specificPattern . setDirective ( generalDirective , EMPTY_STRING_VALUE ) ; } else { resolveValueConflicts ( generalDirective , generalValue , specificPattern ) ; } } }
|
Resolves directive conflicts between two PatternCacheControl objects
|
3,886
|
private static void resolveValueConflicts ( Directive directive , String generalValue , PatternCacheControl specificPattern ) { long generalPatternValue = Long . parseLong ( generalValue ) ; if ( specificPattern . hasDirective ( directive ) ) { long specificPatternValue = Long . parseLong ( specificPattern . getDirectiveValue ( directive ) ) ; if ( specificPatternValue > generalPatternValue ) { specificPattern . setDirective ( directive , generalValue ) ; } return ; } specificPattern . setDirective ( directive , generalValue ) ; }
|
Resolves the conflicts for a given directive between the general pattern and the specific PatternCacheControl
|
3,887
|
public final Object getProperty ( Map context , Object target , Object oname ) throws OgnlException { return super . getProperty ( context , target , oname ) ; }
|
to override them .
|
3,888
|
private static int skipLws ( byte [ ] buf , int start ) { int i ; for ( i = start ; i < buf . length ; i ++ ) { if ( ! isLws ( buf [ i ] ) ) { return i ; } } return i ; }
|
Skip all linear white spaces
|
3,889
|
public static void addValueToHeader ( Map < String , List < String > > headers , String key , String value , boolean singleValued ) { List < String > values = headers . get ( key ) ; if ( values == null ) { values = new ArrayList < > ( 1 ) ; headers . put ( key , values ) ; } if ( singleValued && values . size ( ) == 1 ) { values . set ( 0 , value ) ; } else { values . add ( value ) ; } }
|
Adds an header to the provided map of headers .
|
3,890
|
public static void addKeepAliveHeaders ( Map < String , List < String > > headers ) { StringUtilities . addValueToHeader ( headers , "Keep-Alive" , HttpProxyConstants . DEFAULT_KEEP_ALIVE_TIME , true ) ; StringUtilities . addValueToHeader ( headers , "Proxy-Connection" , "keep-Alive" , true ) ; }
|
Try to force proxy connection to be kept alive .
|
3,891
|
public static String getAccountId ( ) throws IOException { String macUrl = getMetadataUrl ( ) + "/network/interfaces/macs/" ; String mac = invokeUrl ( macUrl ) . trim ( ) ; String idUrl = macUrl + mac + "owner-id" ; String acctId = invokeUrl ( idUrl ) . trim ( ) ; assert acctId != null ; return acctId ; }
|
Returns the AccountId of the user who is running the instance .
|
3,892
|
public static String getRegion ( ) throws IOException { String url = getMetadataUrl ( ) + "/placement/availability-zone" ; String zone = invokeUrl ( url ) ; zone = zone . trim ( ) ; String region = zone . substring ( 0 , zone . length ( ) - 1 ) ; assert region != null ; return region ; }
|
Returns the region in which the instance is running .
|
3,893
|
public static String getSecurityGroupName ( ) throws IOException { String url = getMetadataUrl ( ) + "/security-groups" ; String groups = invokeUrl ( url ) ; if ( ( groups == null ) || ( groups . trim ( ) . length ( ) == 0 ) ) { String msg = "No security-group assigned to the instance" ; throw new IllegalStateException ( msg ) ; } StringTokenizer tokenizer = new StringTokenizer ( groups , "\n" ) ; return tokenizer . nextToken ( ) ; }
|
Returns the name of the security group from the list that is obtained from the resource vendor . An instance may belong to multiple security groups . And the list of security groups obtained from the vendor may not be ordered . If the vendor supports the notion of a default security group then that should be returned . Otherwise the implementation will be vendor - specific .
|
3,894
|
public static String getVersion2SignedRequest ( String requestMethod , String protocol , String endpoint , String requestURI , Map < String , String > params , String awsAccessKeyId , String awsSecretKey ) throws SignatureException { if ( ( requestMethod == null ) || ( protocol == null ) || ( endpoint == null ) || ( requestURI == null ) || ( params == null ) || ( awsAccessKeyId == null ) || ( awsSecretKey == null ) ) { throw new IllegalArgumentException ( "Null parameter passed in" ) ; } params . put ( "AWSAccessKeyId" , awsAccessKeyId ) ; params . put ( "SignatureMethod" , HMAC_SHA256_ALGORITHM ) ; params . put ( "SignatureVersion" , "2" ) ; params . put ( "Timestamp" , getTimestamp ( ) ) ; String canonicalQS = getV2CanonicalizedQueryString ( params ) ; String stringToSign = requestMethod + "\n" + endpoint + "\n" + requestURI + "\n" + canonicalQS ; String signature = createSignature ( stringToSign , awsSecretKey , HMAC_SHA256_ALGORITHM ) ; String request = protocol + "://" + endpoint + requestURI + "?" + canonicalQS + "&Signature=" + signature ; return request ; }
|
This method returns a complete signed request using HmaSHA256 algorithm using the SignatureVersion 2 scheme . Currently this method creates SignatureVersion 2 based signed requests ONLY for the HTTP GET method . It s the callers the responsibility such as Action and such based on the REST API that they are trying to exercise . This method adds SignatureVersion SignatureMethod AWSAccessKeyId Timestamp and Signature parameters to the request .
|
3,895
|
public static String invokeUrl ( String url ) throws IOException { if ( url == null ) { throw new IllegalArgumentException ( "Null parameter passed in" ) ; } URL urlObj ; InputStream inStream = null ; String response = null ; HttpURLConnection connection = null ; try { urlObj = new URL ( url ) ; connection = ( HttpURLConnection ) urlObj . openConnection ( ) ; connection . setRequestMethod ( "GET" ) ; connection . setConnectTimeout ( 2 * 1000 ) ; connection . setReadTimeout ( 2 * 1000 ) ; connection . connect ( ) ; try { inStream = connection . getInputStream ( ) ; } catch ( IOException ex ) { inStream = connection . getErrorStream ( ) ; if ( inStream == null ) { response = ex . getMessage ( ) ; } else { response = getResponse ( inStream ) ; inStream . close ( ) ; inStream = null ; } throw new IOException ( url + "\n" + response , ex ) ; } response = getResponse ( inStream ) ; } finally { if ( inStream != null ) { try { inStream . close ( ) ; } catch ( IOException ioe ) { } } if ( connection != null ) { connection . disconnect ( ) ; } } return response ; }
|
This is a generic method to invoke the REST API . The URL that is passed in should result in a signed request with the Signature query parameter included . It s the caller s responsibility to deal with the return value which may be a simple string or a XML response .
|
3,896
|
private static String rfc3986Conformance ( String s ) { assert s != null ; String out ; if ( s == null ) { return null ; } try { out = URLEncoder . encode ( s , UTF8_CHARSET ) . replace ( "+" , "%20" ) . replace ( "*" , "%2A" ) . replace ( "%7E" , "~" ) ; } catch ( UnsupportedEncodingException e ) { out = s ; } return out ; }
|
Based on RFC 3986 and AWS doc further encode certain characters .
|
3,897
|
private void createMonitoringFile ( ) { String monitoringDirName = getMonitoringDirName ( ) ; monitoringDir = new File ( monitoringDirName ) ; File monitoringFile = new File ( monitoringDir , gatewayId ) ; IoUtil . deleteIfExists ( monitoringFile ) ; monitorFileWriter . initialize ( monitoringFile ) ; }
|
Method creating the monitoring MMF
|
3,898
|
private String getMonitoringDirName ( ) { String monitoringDirName = IoUtil . tmpDirName ( ) + MONITOR_DIR_NAME ; if ( LINUX . equalsIgnoreCase ( System . getProperty ( OS_NAME_SYSTEM_PROPERTY ) ) ) { final File devShmDir = new File ( LINUX_DEV_SHM_DIRECTORY ) ; if ( devShmDir . exists ( ) ) { monitoringDirName = LINUX_DEV_SHM_DIRECTORY + monitoringDirName ; } } return monitoringDirName ; }
|
This method is used to compute the monitoring directory name which will be used by Agrona in order to create a file in which to write the data in shared memory .
|
3,899
|
public static DerId decode ( ByteBuffer buf ) { if ( buf == null || buf . remaining ( ) == 0 ) { throw new IllegalArgumentException ( "Null or empty buffer" ) ; } DerId id = new DerId ( ) ; byte first = buf . get ( ) ; id . tagClass = TagClass . values ( ) [ ( first & 0xc0 ) >> 6 ] ; id . encodingType = EncodingType . values ( ) [ ( first & 0x20 ) >> 5 ] ; int tagNum = first & 0x1f ; if ( tagNum == 0x1F ) { if ( buf . remaining ( ) == 0 ) { throw new IllegalArgumentException ( "Insufficient data to decode tag number greater than 30" ) ; } tagNum = 0 ; while ( buf . hasRemaining ( ) ) { byte octet = buf . get ( ) ; tagNum = ( tagNum << 7 ) + ( octet & 0x7f ) ; if ( ( octet >> 7 ) == 0 ) { break ; } } } id . tagNumber = tagNum ; return id ; }
|
Decodes identifier octets from a DER - encoded message .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.