Input: / * ( non - Javadoc ) [CODESPLIT] public Map < String , ResourceProperties > listDirectory ( String path ) throws Exception { IResponse response = null ; try { IContext context = createContext ( ) ; context . put ( "Depth" , "1" ) ; //$NON-NLS-1$ //$NON-NLS-2$ ILocator locator = WebDAVFactory . locatorFactory . newLocator ( path ) ; response = client . propfind ( locator , context , null ) ; if ( response . getStatusCode ( ) != IResponse . SC_MULTI_STATUS ) { throw new WebDavException ( response ) ; } Map < String , ResourceProperties > res = StreamProcessingUtils . parseListing ( path , response . getInputStream ( ) ) ; addGuvnorResourceProperties ( res , path ) ; return res ; } finally { if ( response != null ) { response . close ( ) ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public ResourceProperties queryProperties ( String resource ) throws Exception { IResponse response = null ; try { IContext context = createContext ( ) ; context . put ( "Depth" , "1" ) ; //$NON-NLS-1$ //$NON-NLS-2$ ILocator locator = WebDAVFactory . locatorFactory . newLocator ( resource ) ; response = client . propfind ( locator , context , null ) ; if ( response . getStatusCode ( ) != IResponse . SC_MULTI_STATUS && response . getStatusCode ( ) != IResponse . SC_OK ) { throw new WebDavException ( response ) ; } Map < String , ResourceProperties > props = StreamProcessingUtils . parseListing ( "" , response . getInputStream ( ) ) ; //$NON-NLS-1$ if ( props . keySet ( ) . size ( ) != 1 ) { throw new Exception ( props . keySet ( ) . size ( ) + " entries found for " + resource ) ; //$NON-NLS-1$ } String fullpath = props . keySet ( ) . iterator ( ) . next ( ) ; ResourceProperties res = props . get ( fullpath ) ; String filename = new Path ( fullpath ) . lastSegment ( ) ; addGuvnorResourceProperties ( res , filename , resource ) ; return res ; } finally { if ( response != null ) { response . close ( ) ; } } }


Input: Adds Guvnor - specific resource properties to the collection . [CODESPLIT] private void addGuvnorResourceProperties ( ResourceProperties props , String filename , String resource ) throws Exception { if ( props == null ) { return ; } IResponse response = null ; try { String path = resource . substring ( 0 , resource . lastIndexOf ( ' ' ) ) ; String apiVer = changeToAPICall ( path ) ; Properties guvProps = new Properties ( ) ; response = getResourceInputStream ( apiVer ) ; guvProps . load ( response . getInputStream ( ) ) ; String val = guvProps . getProperty ( filename ) ; if ( val != null ) { StringTokenizer tokens = new StringTokenizer ( val , "," ) ; //$NON-NLS-1$ //                String dateStamp = tokens.nextToken(); //                String revision = tokens.nextToken(); if ( tokens . hasMoreElements ( ) ) { props . setLastModifiedDate ( tokens . nextToken ( ) ) ; } if ( tokens . hasMoreElements ( ) ) { props . setRevision ( tokens . nextToken ( ) ) ; } } else { Exception nfe = new Exception ( "Failed to get Guvnor properties for " + filename ) ; //$NON-NLS-1$ Activator . getDefault ( ) . writeLog ( IStatus . WARNING , nfe . getMessage ( ) , nfe ) ; } } finally { if ( response != null ) { response . close ( ) ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public String getResourceContents ( String resource ) throws Exception { IResponse response = null ; try { response = getResourceInputStream ( resource ) ; return StreamProcessingUtils . getStreamContents ( response . getInputStream ( ) ) ; } finally { if ( response != null ) { response . close ( ) ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public String getResourceVersionContents ( String resource , String version ) throws Exception { String apiVer = changeToAPICall ( resource ) + "?version=" + version ; //$NON-NLS-1$ return getResourceContents ( apiVer ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public IResponse getResourceInputStream ( String resource ) throws Exception { ILocator locator = WebDAVFactory . locatorFactory . newLocator ( resource ) ; IResponse response = client . get ( locator , createContext ( ) ) ; if ( response . getStatusCode ( ) != IResponse . SC_OK ) { throw new WebDavException ( response ) ; } return response ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public IResponse getResourceVersionInputStream ( String resource , String version ) throws Exception { String apiVer = changeToAPICall ( resource ) + "?version=" + version ; //$NON-NLS-1$ return getResourceInputStream ( apiVer ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean createResource ( String resource , InputStream is ) throws Exception { return createResource ( resource , is , true ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean createResource ( String resource , InputStream is , boolean overwrite ) throws Exception { boolean res = true ; if ( ! overwrite ) { try { if ( queryProperties ( resource ) != null ) { res = false ; } } catch ( WebDavException e ) { if ( e . getErrorCode ( ) != IResponse . SC_NOT_FOUND ) { throw e ; } } } IResponse response = null ; try { if ( res ) { ILocator locator = WebDAVFactory . locatorFactory . newLocator ( resource ) ; response = client . put ( locator , createContext ( ) , is ) ; if ( response . getStatusCode ( ) != IResponse . SC_OK && response . getStatusCode ( ) != IResponse . SC_CREATED ) { throw new WebDavException ( response ) ; } } } finally { if ( response != null ) { response . close ( ) ; } } return res ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void putResource ( String resource , InputStream is ) throws Exception { IResponse response = null ; try { ILocator locator = WebDAVFactory . locatorFactory . newLocator ( resource ) ; response = client . put ( locator , createContext ( ) , is ) ; if ( response . getStatusCode ( ) != IResponse . SC_OK && response . getStatusCode ( ) != IResponse . SC_NO_CONTENT && response . getStatusCode ( ) != IResponse . SC_CREATED ) { throw new WebDavException ( response ) ; } } finally { if ( response != null ) { response . close ( ) ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public IResponse getResourceVersions ( String resource ) throws Exception { String apiVer = changeToAPICall ( resource ) + "?version=all" ; //$NON-NLS-1$ return getResourceInputStream ( apiVer ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void deleteResource ( String resource ) throws Exception { IResponse response = null ; try { ILocator locator = WebDAVFactory . locatorFactory . newLocator ( resource ) ; response = client . delete ( locator , createContext ( ) ) ; if ( response . getStatusCode ( ) != IResponse . SC_NO_CONTENT && response . getStatusCode ( ) != IResponse . SC_OK ) { throw new WebDavException ( response ) ; } } finally { if ( response != null ) { response . close ( ) ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public void run ( IAction action ) { if ( selectedItems == null ) { return ; } String msg = null ; if ( selectedItems . size ( ) == 1 ) { msg = MessageFormat . format ( Messages . getString ( "delete.singlefile.confirmation" ) , //$NON-NLS-1$ new Object [ ] { ( ( IFile ) selectedItems . getFirstElement ( ) ) . getName ( ) } ) ; } else { msg = MessageFormat . format ( Messages . getString ( "delete.multifile.confirmation" ) , //$NON-NLS-1$ new Object [ ] { String . valueOf ( selectedItems . size ( ) ) } ) ; } if ( ! MessageDialog . openConfirm ( targetPart . getSite ( ) . getShell ( ) , Messages . getString ( "delete.confirmation.dialog.caption" ) , msg ) ) { //$NON-NLS-1$ return ; } for ( Iterator it = selectedItems . iterator ( ) ; it . hasNext ( ) ; ) { Object oneItem = it . next ( ) ; if ( oneItem instanceof IFile ) { processDelete ( ( IFile ) oneItem ) ; } } DisconnectAction dsAction = new DisconnectAction ( ) ; dsAction . disconnect ( selectedItems ) ; PlatformUtils . updateDecoration ( ) ; PlatformUtils . refreshRepositoryView ( ) ; }


Input: Create a new version - controlled configuration on the given baseline . [CODESPLIT] public void baselineControl ( ILocator baseline ) throws DAVException { Assert . isNotNull ( baseline ) ; // Build the document body to describe the baseline control element. Document document = newDocument ( ) ; Element root = ElementEditor . create ( document , "baseline-control" ) ; //$NON-NLS-1$ ElementEditor . addChild ( root , "baseline" , //$NON-NLS-1$ baseline . getResourceURL ( ) , new String [ ] { "baseline" } , //$NON-NLS-1$ true ) ; // Send the baseline control method to the server and check the response. IResponse response = null ; try { response = davClient . baselineControl ( locator , newContext ( ) , document ) ; examineResponse ( response ) ; } catch ( IOException e ) { throw new SystemException ( e ) ; } finally { closeResponse ( response ) ; } }


Input: Binds the given member in this collection to the resource identified by the given source locator . If the member already exists or is already bound to a resource it is not replaced . [CODESPLIT] public void bind ( String member , ILocator source ) throws DAVException { bind ( member , source , false ) ; }


Input: Binds the given member in this collection to the resource identified by the given source locator . If overwrite is <code > false< / code > and such a member already exists or such a member is already bound to a resource it is not replaced . Otherwise if overwrite is <code > true< / code > and such a member already exists or such a member is already bound to a resource it is replaced . [CODESPLIT] public void bind ( String member , ILocator source , boolean overwrite ) throws DAVException { IContext context = newContext ( ) ; context . setOverwrite ( overwrite ) ; ILocator destination = getMember ( member ) ; IResponse response = null ; try { response = davClient . bind ( source , destination , context ) ; examineResponse ( response ) ; } catch ( IOException e ) { throw new SystemException ( e ) ; } finally { closeResponse ( response ) ; } }


Input: Return the locator of the member of this collection with the given name . Does NOT perform a call to the server to check the existence of the member . [CODESPLIT] public ILocator getMember ( String memberName ) { Assert . isTrue ( locator . getLabel ( ) == null ) ; Assert . isTrue ( ! locator . isStable ( ) ) ; String parentName = locator . getResourceURL ( ) ; String childName ; if ( parentName . endsWith ( "/" ) ) //$NON-NLS-1$ childName = parentName + memberName ; else childName = parentName + "/" + memberName ; //$NON-NLS-1$ return davClient . getDAVFactory ( ) . newLocator ( childName ) ; }


Input: Return a set of handles representing the members of this collection . <p > Each member of the set will be typed to be a <code > ResourceHandle< / code > or a <code > CollectionHandle< / code > depending upon whether it implements collection semantics . Note that workspaces will be returned as regular collection handles and should be converted to workspace handles if required ( test using isWorkspace () ) . < / p > [CODESPLIT] public Set getMembers ( ) throws DAVException { // Query the DAV:resource-type property to depth one. Collection querySet = new Vector ( ) ; querySet . add ( DAV_RESOURCE_TYPE ) ; URLTable resourceTable = getProperties ( querySet , IContext . DEPTH_ONE ) ; // Create a collection for the reply, and remove // ourselves from the answer. Set reply = new HashSet ( ) ; try { resourceTable . remove ( locator . getResourceURL ( ) ) ; } catch ( MalformedURLException exception ) { throw new DAVException ( Policy . bind ( "exception.malformedLocator" ) ) ; //$NON-NLS-1$ } // The keys of the result correspond to the receiver's internal members. Enumeration resourceNameEnum = resourceTable . keys ( ) ; while ( resourceNameEnum . hasMoreElements ( ) ) { URL url = ( URL ) resourceNameEnum . nextElement ( ) ; // Get the props for that resource Hashtable propertyTable = ( Hashtable ) resourceTable . get ( url ) ; Assert . isNotNull ( propertyTable ) ; PropertyStatus propertyStatus = ( PropertyStatus ) propertyTable . get ( DAV_RESOURCE_TYPE ) ; Assert . isNotNull ( propertyStatus ) ; // If we have a DAV:collection element, then create a collection handle, // all other resource types are created as regular resource handles. ILocator newLocator = davClient . getDAVFactory ( ) . newLocator ( url . toString ( ) ) ; Element property = propertyStatus . getProperty ( ) ; try { if ( ElementEditor . hasChild ( property , DAV_COLLECTION_RESOURCE_TYPE ) ) reply . add ( new CollectionHandle ( davClient , newLocator ) ) ; else reply . add ( new ResourceHandle ( davClient , newLocator ) ) ; } catch ( MalformedElementException exception ) { throw new SystemException ( exception ) ; } } // end-while return reply ; }


Input: Optimizing vertices for optimal presentation [CODESPLIT] public void optimize ( ) { final List < BaseVertex > sorted = new ArrayList < BaseVertex > ( this . vertices ) ; Collections . sort ( sorted , new Comparator < BaseVertex > ( ) { public int compare ( final BaseVertex v1 , final BaseVertex v2 ) { int v1OutDegree = v1 . getSourceConnections ( ) . size ( ) ; int v2OutDegree = v2 . getSourceConnections ( ) . size ( ) ; if ( v1OutDegree < v2OutDegree ) { return 1 ; } if ( v1OutDegree > v2OutDegree ) { return - 1 ; } return 0 ; } } ) ; final LinkedList < BaseVertex > optimized = new LinkedList < BaseVertex > ( ) ; boolean front = false ; for ( final Iterator < BaseVertex > vertexIter = sorted . iterator ( ) ; vertexIter . hasNext ( ) ; ) { final BaseVertex vertex = vertexIter . next ( ) ; if ( front ) { optimized . addFirst ( vertex ) ; } else { optimized . addLast ( vertex ) ; } front = ! front ; } this . vertices = optimized ; }


Input: Authorizes the given request by setting its authorization credentials in the given context . If the given response is not <code > null< / code > it is assumed to contain an authenticate challenge that is used to derive the authorization credentials . Returns true if the authorization succeeds and false otherwise . [CODESPLIT] public boolean authorize ( Request request , IResponse response , IContext context , URL proxyServerUrl , boolean isProxyAuthorization ) { Assert . isNotNull ( request ) ; Assert . isNotNull ( context ) ; URL serverUrl = null ; URL protectionSpaceUrl = null ; if ( isProxyAuthorization ) { if ( proxyServerUrl == null ) { return false ; } serverUrl = proxyServerUrl ; protectionSpaceUrl = proxyServerUrl ; } else { URL resourceUrl = request . getResourceUrl ( ) ; try { serverUrl = new URL ( resourceUrl . getProtocol ( ) , resourceUrl . getHost ( ) , resourceUrl . getPort ( ) , "/" ) ; //$NON-NLS-1$ } catch ( MalformedURLException e ) { return false ; } protectionSpaceUrl = resourceUrl ; } if ( response != null ) { String challengeString = null ; if ( isProxyAuthorization ) { challengeString = response . getContext ( ) . getProxyAuthenticate ( ) ; } else { challengeString = response . getContext ( ) . getWWWAuthenticate ( ) ; } if ( challengeString == null ) { return false ; } AuthenticateChallenge challenge = null ; try { challenge = new AuthenticateChallenge ( challengeString ) ; } catch ( ParserException e ) { return false ; } String authScheme = challenge . getAuthScheme ( ) ; String realm = challenge . getRealm ( ) ; AuthorizationAuthority authority = getAuthorizationAuthority ( authScheme ) ; if ( authority == null ) { return false ; } Map oldInfo = authenticatorStore . getAuthenticationInfo ( serverUrl , realm , authScheme ) ; Map info = authority . getAuthenticationInfo ( challenge , oldInfo , serverUrl , protectionSpaceUrl ) ; if ( info == null ) { return false ; } authenticatorStore . addAuthenticationInfo ( serverUrl , realm , authScheme , info ) ; authenticatorStore . addProtectionSpace ( protectionSpaceUrl , realm ) ; } String realm = authenticatorStore . getProtectionSpace ( protectionSpaceUrl ) ; if ( realm == null ) { return false ; } Map info = null ; String authScheme = null ; for ( int i = 0 ; i < authenticationSchemes . length ; ++ i ) { authScheme = authenticationSchemes [ i ] ; info = authenticatorStore . getAuthenticationInfo ( serverUrl , realm , authScheme ) ; if ( info != null ) { break ; } } if ( info == null ) { return false ; } AuthorizationAuthority authority = getAuthorizationAuthority ( authScheme ) ; if ( authority == null ) { return false ; } String authorization = authority . getAuthorization ( request , info , serverUrl , protectionSpaceUrl , proxyServerUrl ) ; if ( authorization == null ) { return false ; } if ( isProxyAuthorization ) { if ( authorization . equals ( context . getProxyAuthorization ( ) ) ) return false ; // we already had that auth so it must've failed context . setProxyAuthorization ( authorization ) ; } else { if ( authorization . equals ( context . getAuthorization ( ) ) ) return false ; // we already had that auth so it must've failed context . setAuthorization ( authorization ) ; } return true ; }


Input: Confirms whether the given response is valid by proving the server knows the client s authentication secret ( password ) . Moreover the server may wish to communicate some authentication information in the response for the purposes of authorizing future request . [CODESPLIT] public boolean confirm ( Request request , IResponse response , URL proxyServerUrl ) { Assert . isNotNull ( request ) ; Assert . isNotNull ( response ) ; URL resourceUrl = request . getResourceUrl ( ) ; URL serverUrl = null ; try { serverUrl = new URL ( resourceUrl . getProtocol ( ) , resourceUrl . getHost ( ) , resourceUrl . getPort ( ) , "/" ) ; //$NON-NLS-1$ } catch ( MalformedURLException e ) { return false ; } String realm = authenticatorStore . getProtectionSpace ( resourceUrl ) ; if ( realm == null ) { return false ; } Map info = null ; String authScheme = null ; for ( int i = 0 ; i < authenticationSchemes . length ; ++ i ) { authScheme = authenticationSchemes [ i ] ; info = authenticatorStore . getAuthenticationInfo ( serverUrl , realm , authScheme ) ; if ( info != null ) { break ; } } if ( info == null ) { return false ; } AuthorizationAuthority authority = getAuthorizationAuthority ( authScheme ) ; if ( authority == null ) { return false ; } return authority . confirmResponse ( request , response , proxyServerUrl ) ; }


Input: Confirms whether the given response is valid by proving the server knows the client s authentication secret ( password ) . Moreover the server may wish to communicate some authentication information in the response for the purposes of authorizing future request . <p > This method should be overridden by schema specific authenticators . [CODESPLIT] protected boolean confirmResponse ( Request request , IResponse response , URL proxyServerUrl ) { Assert . isNotNull ( request ) ; Assert . isNotNull ( response ) ; return false ; }


Input: Returns the new authentication information gleaned from the given authenticate challenge and the given old authentication information . The old authentication information may be <code > null< / code > . The authentication information usually contains directives such as usernames and passwords . <p > This method should be overridden by schema specific authenticators . [CODESPLIT] protected Map getAuthenticationInfo ( AuthenticateChallenge challenge , Map oldInfo , URL serverUrl , URL protectionSpaceUrl ) { Assert . isNotNull ( challenge ) ; Assert . isNotNull ( serverUrl ) ; Assert . isNotNull ( protectionSpaceUrl ) ; return null ; }


Input: Returns the authorization credentials for the given request . The authorization credentials are derived from the given authentication info . The authentication info may contain directives such as usernames and passwords . <p > This method should be overridden by schema specific authenticators . [CODESPLIT] protected String getAuthorization ( Request request , Map info , URL serverUrl , URL protectionSpaceUrl , URL proxyServerUrl ) { Assert . isNotNull ( request ) ; Assert . isNotNull ( info ) ; Assert . isNotNull ( serverUrl ) ; Assert . isNotNull ( protectionSpaceUrl ) ; return null ; }


Input: Returns an authorization authority for the given authentication scheme or <code > null< / code > if there is no such authority . [CODESPLIT] private AuthorizationAuthority getAuthorizationAuthority ( String scheme ) { try { scheme = Character . toUpperCase ( scheme . charAt ( 0 ) ) + scheme . substring ( 1 ) . toLowerCase ( ) ; String packageName = "org.eclipse.webdav.internal.authentication" ; //$NON-NLS-1$ String className = scheme + "Authority" ; //$NON-NLS-1$ Class clazz = Class . forName ( packageName + "." + className ) ; //$NON-NLS-1$ Constructor constructor = clazz . getConstructor ( new Class [ ] { IAuthenticator . class } ) ; return ( AuthorizationAuthority ) constructor . newInstance ( new Object [ ] { authenticatorStore } ) ; } catch ( ClassCastException e ) { // ignore or log? } catch ( Exception e ) { // ignore or log? } return null ; }


Input: Computes the MD5 hash value of the given <code > String< / code > and returns the result as a HEX <code > String< / code > . [CODESPLIT] protected String md5 ( String s ) throws NoSuchAlgorithmException , UnsupportedEncodingException { MessageDigest md5 = MessageDigest . getInstance ( "MD5" ) ; //$NON-NLS-1$ byte [ ] hash = md5 . digest ( s . getBytes ( "UTF8" ) ) ; //$NON-NLS-1$ return HexConverter . toHex ( hash ) ; }


Input: Computes the MD5 hash value of the body of the given request and returns the result as a HEX <code > String< / code > . [CODESPLIT] protected String md5 ( Request request ) throws NoSuchAlgorithmException , IOException { DigestOutputStream dos = new DigestOutputStream ( "MD5" ) ; //$NON-NLS-1$ request . write ( dos ) ; String result = HexConverter . toHex ( dos . digest ( ) ) ; dos . close ( ) ; return result ; }


Input: Returns the given <code > String< / code > with its quotes removed . [CODESPLIT] protected String unquote ( String s ) { if ( s . charAt ( 0 ) == ' ' && s . charAt ( s . length ( ) - 1 ) == ' ' ) //$NON-NLS-1$ //$NON-NLS-2$ return s . substring ( 1 , s . length ( ) - 1 ) ; return s ; }


Input: Create a ConditionFactor ( either a StateToken or EntityTag ) by parsing the tokenizer contining an If header value . [CODESPLIT] public static ConditionFactor create ( StreamTokenizer tokenizer ) throws WebDAVException { boolean not = false ; ConditionFactor factor = null ; try { int token = tokenizer . ttype ; if ( token == StreamTokenizer . TT_WORD ) { if ( tokenizer . sval . equalsIgnoreCase ( "Not" ) ) { //$NON-NLS-1$ not = true ; } else { throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissingNot" ) ) ; //$NON-NLS-1$ } token = tokenizer . nextToken ( ) ; } switch ( token ) { case ' ' : factor = StateToken . create ( tokenizer ) ; break ; case ' ' : factor = EntityTag . create ( tokenizer ) ; break ; default : throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissingOpen" , String . valueOf ( token ) ) ) ; //$NON-NLS-1$ } } catch ( IOException exc ) { // ignore or log? } factor . setNot ( not ) ; return factor ; }


Input: Repository [CODESPLIT] @ Override public void createRepository ( final IKieRepositoryHandler repository ) throws IOException { runJob ( "Request to create repository '" + repository . getName ( ) + "'" , new Requester . Action ( ) { @ Override public String execute ( ) throws IOException { return httpPost ( "spaces/" + repository . getParent ( ) . getName ( ) + "/projects/" , repository . getProperties ( ) ) ; } } ) ; }


Input: Initializes the controls of this dialog . [CODESPLIT] private void initializeControls ( ) { if ( originalFile != null ) { resourceGroup . setContainerFullPath ( originalFile . getParent ( ) . getFullPath ( ) ) ; String fileName = originalFile . getName ( ) ; int index = fileName . lastIndexOf ( "." ) ; if ( index != - 1 ) { fileName = fileName . substring ( 0 , index ) ; } fileName += "-image.png" ; resourceGroup . setResource ( fileName ) ; } else if ( originalName != null ) { resourceGroup . setResource ( originalName ) ; } setDialogComplete ( validatePage ( ) ) ; }


Input: / * ( non - Javadoc ) Method declared on Dialog . [CODESPLIT] protected void okPressed ( ) { // Get new path. IPath path = resourceGroup . getContainerFullPath ( ) . append ( resourceGroup . getResource ( ) ) ; //If the user does not supply a file extension and if the save  //as dialog was provided a default file name append the extension  //of the default filename to the new name if ( path . getFileExtension ( ) == null ) { if ( originalFile != null && originalFile . getFileExtension ( ) != null ) { path = path . addFileExtension ( originalFile . getFileExtension ( ) ) ; } else if ( originalName != null ) { int pos = originalName . lastIndexOf ( ' ' ) ; if ( ++ pos > 0 && pos < originalName . length ( ) ) { path = path . addFileExtension ( originalName . substring ( pos ) ) ; } } } // If the path already exists then confirm overwrite. IFile file = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) . getFile ( path ) ; if ( file . exists ( ) ) { String [ ] buttons = new String [ ] { IDialogConstants . YES_LABEL , IDialogConstants . NO_LABEL , IDialogConstants . CANCEL_LABEL } ; String question = NLS . bind ( IDEWorkbenchMessages . SaveAsDialog_overwriteQuestion , path . toString ( ) ) ; MessageDialog d = new MessageDialog ( getShell ( ) , IDEWorkbenchMessages . Question , null , question , MessageDialog . QUESTION , buttons , 0 ) ; int overwrite = d . open ( ) ; switch ( overwrite ) { case 0 : // Yes break ; case 1 : // No return ; case 2 : // Cancel default : cancelPressed ( ) ; return ; } } // Store path and close. result = path ; close ( ) ; }


Input: Returns whether this page s visual components all contain valid values . [CODESPLIT] private boolean validatePage ( ) { if ( ! resourceGroup . areAllValuesValid ( ) ) { if ( ! resourceGroup . getResource ( ) . equals ( "" ) ) { //$NON-NLS-1$ setErrorMessage ( resourceGroup . getProblemMessage ( ) ) ; } else { setErrorMessage ( null ) ; } return false ; } String resourceName = resourceGroup . getResource ( ) ; IWorkspace workspace = ResourcesPlugin . getWorkspace ( ) ; // Do not allow a closed project to be selected IPath fullPath = resourceGroup . getContainerFullPath ( ) ; if ( fullPath != null ) { String projectName = fullPath . segment ( 0 ) ; IStatus isValidProjectName = workspace . validateName ( projectName , IResource . PROJECT ) ; if ( isValidProjectName . isOK ( ) ) { IProject project = workspace . getRoot ( ) . getProject ( projectName ) ; if ( ! project . isOpen ( ) ) { setErrorMessage ( IDEWorkbenchMessages . SaveAsDialog_closedProjectMessage ) ; return false ; } } } IStatus result = workspace . validateName ( resourceName , IResource . FILE ) ; if ( ! result . isOK ( ) ) { setErrorMessage ( result . getMessage ( ) ) ; return false ; } setErrorMessage ( null ) ; return true ; }


Input: / * ( non - Javadoc ) @see org . eclipse . jface . window . Dialog#getDialogBoundsSettings () [CODESPLIT] protected IDialogSettings getDialogBoundsSettings ( ) { IDialogSettings settings = IDEWorkbenchPlugin . getDefault ( ) . getDialogSettings ( ) ; IDialogSettings section = settings . getSection ( DIALOG_SETTINGS_SECTION ) ; if ( section == null ) { section = settings . addNewSection ( DIALOG_SETTINGS_SECTION ) ; } return section ; }


Input: Create an EntityTag by parsing the given If header as defined by section 3 . 11 of the HTTP / 1 . 1 spec . [CODESPLIT] public static ConditionFactor create ( StreamTokenizer tokenizer ) throws WebDAVException { EntityTag entityTag = new EntityTag ( ) ; try { int token = tokenizer . ttype ; if ( token == ' ' ) token = tokenizer . nextToken ( ) ; else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , "[" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ if ( token == ' ' ) { //$NON-NLS-1$ entityTag . setETag ( tokenizer . sval ) ; token = tokenizer . nextToken ( ) ; } else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissingQuotedString" , String . valueOf ( token ) ) ) ; //$NON-NLS-1$ if ( token == ' ' ) token = tokenizer . nextToken ( ) ; else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , "]" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } catch ( IOException exc ) { // ignore or log? } return entityTag ; }


Input: Construct a unique EntityTag . The tag is constructed by concatening the current time with the current thread s hash code . [CODESPLIT] public static EntityTag generateEntityTag ( ) { String xx = basetime + ":" + Integer . toHexString ( Thread . currentThread ( ) . hashCode ( ) ) ; //$NON-NLS-1$ bcnt ++ ; xx += ":" + bcnt ; //$NON-NLS-1$ return new EntityTag ( xx ) ; }


Input: Create a new workspace in the location described by this handle . <p > A new workspace is created using a MKWORKSPACE method call . < / p > [CODESPLIT] public void create ( ) throws DAVException { Document document = newDocument ( ) ; Mkworkspace . create ( document ) ; IResponse response = null ; try { response = davClient . mkworkspace ( locator , newContext ( ) , document ) ; examineResponse ( response ) ; } catch ( IOException e ) { throw new SystemException ( e ) ; } finally { closeResponse ( response ) ; } }


Input: Gets opposite of specified vertex . [CODESPLIT] public BaseVertex getOpposite ( BaseVertex vertex ) { // If null or not part of this connection if ( vertex == null || ( ! vertex . equals ( getSource ( ) ) && ! vertex . equals ( getTarget ( ) ) ) ) { return null ; } if ( vertex . equals ( getSource ( ) ) ) { return getTarget ( ) ; } return getSource ( ) ; }


Input: 生成ECC密钥对 [CODESPLIT] public static AsymmetricCipherKeyPair generateKeyPairParameter ( ECDomainParameters domainParameters , SecureRandom random ) { ECKeyGenerationParameters keyGenerationParams = new ECKeyGenerationParameters ( domainParameters , random ) ; ECKeyPairGenerator keyGen = new ECKeyPairGenerator ( ) ; keyGen . init ( keyGenerationParams ) ; return keyGen . generateKeyPair ( ) ; }


Input: 将ECC私钥转换为PKCS8标准的字节流 [CODESPLIT] public static byte [ ] convertECPrivateKeyToPKCS8 ( ECPrivateKeyParameters priKey , ECPublicKeyParameters pubKey ) { ECDomainParameters domainParams = priKey . getParameters ( ) ; ECParameterSpec spec = new ECParameterSpec ( domainParams . getCurve ( ) , domainParams . getG ( ) , domainParams . getN ( ) , domainParams . getH ( ) ) ; BCECPublicKey publicKey = null ; if ( pubKey != null ) { publicKey = new BCECPublicKey ( ALGO_NAME_EC , pubKey , spec , BouncyCastleProvider . CONFIGURATION ) ; } BCECPrivateKey privateKey = new BCECPrivateKey ( ALGO_NAME_EC , priKey , publicKey , spec , BouncyCastleProvider . CONFIGURATION ) ; return privateKey . getEncoded ( ) ; }


Input: 将PKCS8标准的私钥字节流转换为私钥对象 [CODESPLIT] public static BCECPrivateKey convertPKCS8ToECPrivateKey ( byte [ ] pkcs8Key ) throws NoSuchAlgorithmException , NoSuchProviderException , InvalidKeySpecException { PKCS8EncodedKeySpec peks = new PKCS8EncodedKeySpec ( pkcs8Key ) ; KeyFactory kf = KeyFactory . getInstance ( ALGO_NAME_EC , BouncyCastleProvider . PROVIDER_NAME ) ; return ( BCECPrivateKey ) kf . generatePrivate ( peks ) ; }


Input: 将ECC私钥转换为SEC1标准的字节流 openssl d2i_ECPrivateKey函数要求的DER编码的私钥也是SEC1标准的， 这个工具函数的主要目的就是为了能生成一个openssl可以直接“识别”的ECC私钥 . 相对RSA私钥的PKCS1标准，ECC私钥的标准为SEC1 [CODESPLIT] public static byte [ ] convertECPrivateKeyToSEC1 ( ECPrivateKeyParameters priKey , ECPublicKeyParameters pubKey ) throws IOException { byte [ ] pkcs8Bytes = convertECPrivateKeyToPKCS8 ( priKey , pubKey ) ; PrivateKeyInfo pki = PrivateKeyInfo . getInstance ( pkcs8Bytes ) ; ASN1Encodable encodable = pki . parsePrivateKey ( ) ; ASN1Primitive primitive = encodable . toASN1Primitive ( ) ; byte [ ] sec1Bytes = primitive . getEncoded ( ) ; return sec1Bytes ; }


Input:
将SEC1标准的私钥字节流恢复为PKCS8标准的字节流 [CODESPLIT] public static byte [ ] convertECPrivateKeySEC1ToPKCS8 ( byte [ ] sec1Key ) throws IOException { /**
         * 参考org.bouncycastle.asn1.pkcs.PrivateKeyInfo和
         * org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey，逆向拼装
         */ X962Parameters params = getDomainParametersFromName ( SM2Util . JDK_EC_SPEC , false ) ; ASN1OctetString privKey = new DEROctetString ( sec1Key ) ; ASN1EncodableVector v = new ASN1EncodableVector ( ) ; v . add ( new ASN1Integer ( 0 ) ) ; //版本号 v . add ( new AlgorithmIdentifier ( X9ObjectIdentifiers . id_ecPublicKey , params ) ) ; //算法标识 v . add ( privKey ) ; DERSequence ds = new DERSequence ( v ) ; return ds . getEncoded ( ASN1Encoding . DER ) ; }


Input: 将SEC1标准的私钥字节流转为BCECPrivateKey对象 [CODESPLIT] public static BCECPrivateKey convertSEC1ToBCECPrivateKey ( byte [ ] sec1Key ) throws NoSuchAlgorithmException , NoSuchProviderException , InvalidKeySpecException , IOException { PKCS8EncodedKeySpec peks = new PKCS8EncodedKeySpec ( convertECPrivateKeySEC1ToPKCS8 ( sec1Key ) ) ; KeyFactory kf = KeyFactory . getInstance ( ALGO_NAME_EC , BouncyCastleProvider . PROVIDER_NAME ) ; return ( BCECPrivateKey ) kf . generatePrivate ( peks ) ; }


Input: 将SEC1标准的私钥字节流转为ECPrivateKeyParameters对象 openssl i2d_ECPrivateKey函数生成的DER编码的ecc私钥是：SEC1标准的、带有EC_GROUP、带有公钥的， 这个工具函数的主要目的就是为了使Java程序能够“识别”openssl生成的ECC私钥 [CODESPLIT] public static ECPrivateKeyParameters convertSEC1ToECPrivateKey ( byte [ ] sec1Key ) throws NoSuchAlgorithmException , NoSuchProviderException , InvalidKeySpecException , IOException { BCECPrivateKey privateKey = convertSEC1ToBCECPrivateKey ( sec1Key ) ; return convertPrivateKeyToParameters ( privateKey ) ; }


Input: 将ECC公钥对象转换为X509标准的字节流 [CODESPLIT] public static byte [ ] convertECPublicKeyToX509 ( ECPublicKeyParameters pubKey ) { ECDomainParameters domainParams = pubKey . getParameters ( ) ; ECParameterSpec spec = new ECParameterSpec ( domainParams . getCurve ( ) , domainParams . getG ( ) , domainParams . getN ( ) , domainParams . getH ( ) ) ; BCECPublicKey publicKey = new BCECPublicKey ( ALGO_NAME_EC , pubKey , spec , BouncyCastleProvider . CONFIGURATION ) ; return publicKey . getEncoded ( ) ; }


Input: 将X509标准的公钥字节流转为公钥对象 [CODESPLIT] public static BCECPublicKey convertX509ToECPublicKey ( byte [ ] x509Bytes ) throws NoSuchProviderException , NoSuchAlgorithmException , InvalidKeySpecException { X509EncodedKeySpec eks = new X509EncodedKeySpec ( x509Bytes ) ; KeyFactory kf = KeyFactory . getInstance ( "EC" , BouncyCastleProvider . PROVIDER_NAME ) ; return ( BCECPublicKey ) kf . generatePublic ( eks ) ; }


Input: copy from BC [CODESPLIT] public static X9ECParameters getDomainParametersFromName ( String curveName ) { X9ECParameters domainParameters ; try { if ( curveName . charAt ( 0 ) >= ' ' && curveName . charAt ( 0 ) <= ' ' ) { ASN1ObjectIdentifier oidID = new ASN1ObjectIdentifier ( curveName ) ; domainParameters = ECUtil . getNamedCurveByOid ( oidID ) ; } else { if ( curveName . indexOf ( ' ' ) > 0 ) { curveName = curveName . substring ( curveName . indexOf ( ' ' ) + 1 ) ; domainParameters = ECUtil . getNamedCurveByName ( curveName ) ; } else { domainParameters = ECUtil . getNamedCurveByName ( curveName ) ; } } } catch ( IllegalArgumentException ex ) { domainParameters = ECUtil . getNamedCurveByName ( curveName ) ; } return domainParameters ; }


Input: copy from BC [CODESPLIT] public static X962Parameters getDomainParametersFromName ( java . security . spec . ECParameterSpec ecSpec , boolean withCompression ) { X962Parameters params ; if ( ecSpec instanceof ECNamedCurveSpec ) { ASN1ObjectIdentifier curveOid = ECUtil . getNamedCurveOid ( ( ( ECNamedCurveSpec ) ecSpec ) . getName ( ) ) ; if ( curveOid == null ) { curveOid = new ASN1ObjectIdentifier ( ( ( ECNamedCurveSpec ) ecSpec ) . getName ( ) ) ; } params = new X962Parameters ( curveOid ) ; } else if ( ecSpec == null ) { params = new X962Parameters ( DERNull . INSTANCE ) ; } else { ECCurve curve = EC5Util . convertCurve ( ecSpec . getCurve ( ) ) ; X9ECParameters ecP = new X9ECParameters ( curve , EC5Util . convertPoint ( curve , ecSpec . getGenerator ( ) , withCompression ) , ecSpec . getOrder ( ) , BigInteger . valueOf ( ecSpec . getCofactor ( ) ) , ecSpec . getCurve ( ) . getSeed ( ) ) ; params = new X962Parameters ( ecP ) ; } return params ; }


Input: 加密数据 [CODESPLIT] public static byte [ ] encrypt ( String srcData , String publicKey ) throws Exception { if ( RUNNING_PUBLIC_KEY == null ) { try { LOCK . lock ( ) ; if ( RUNNING_PUBLIC_KEY == null ) { ECPoint ecPoint = CURVE . decodePoint ( Base64 . decode ( publicKey . toCharArray ( ) ) ) ; RUNNING_PUBLIC_KEY = new ECPublicKeyParameters ( ecPoint , DOMAIN_PARAMS ) ; } } catch ( Exception e ) { throw new RuntimeException ( "init public key error" , e ) ; } finally { LOCK . unlock ( ) ; } } return encrypt ( RUNNING_PUBLIC_KEY , srcData . getBytes ( ) ) ; }


Input: 只获取公钥里的XY分量，64字节 [CODESPLIT] public static byte [ ] getRawPublicKey ( BCECPublicKey publicKey ) { byte [ ] src65 = publicKey . getQ ( ) . getEncoded ( false ) ; byte [ ] rawXY = new byte [ CURVE_LEN * 2 ] ; //SM2的话这里应该是64字节 System . arraycopy ( src65 , 1 , rawXY , 0 , rawXY . length ) ; return rawXY ; }


Input: ECC公钥加密 [CODESPLIT] public static byte [ ] encrypt ( ECPublicKeyParameters pubKeyParameters , byte [ ] srcData ) throws InvalidCipherTextException { SM2Engine engine = new SM2Engine ( ) ; ParametersWithRandom pwr = new ParametersWithRandom ( pubKeyParameters , new SecureRandom ( ) ) ; engine . init ( true , pwr ) ; return engine . processBlock ( srcData , 0 , srcData . length ) ; }


Input: ECC私钥解密 [CODESPLIT] public static byte [ ] decrypt ( ECPrivateKeyParameters priKeyParameters , byte [ ] sm2Cipher ) throws InvalidCipherTextException { SM2Engine engine = new SM2Engine ( ) ; engine . init ( false , priKeyParameters ) ; return engine . processBlock ( sm2Cipher , 0 , sm2Cipher . length ) ; }


Input: Sums two { [CODESPLIT] public static InsertMetrics sum ( InsertMetrics m1 , InsertMetrics m2 ) { long totalDocsInserted = m1 . numberOfDocumentsInserted + m2 . numberOfDocumentsInserted ; Duration totalTimeTaken = m1 . timeTaken . plus ( m2 . timeTaken ) ; double totalRequestUnitsConsumed = m1 . requestUnitsConsumed + m2 . requestUnitsConsumed ; long totalNumberOfThrottles = m1 . numberOfThrottles + m2 . numberOfThrottles ; return new InsertMetrics ( totalDocsInserted , totalTimeTaken , totalRequestUnitsConsumed , totalNumberOfThrottles ) ; }


Input: Releases any internal resources . It is responsibility of the caller to close { [CODESPLIT] @ Override public void close ( ) { // disable submission of new tasks listeningExecutorService . shutdown ( ) ; try { // wait for existing tasks to terminate if ( ! listeningExecutorService . awaitTermination ( 60 , TimeUnit . SECONDS ) ) { // cancel any currently running executing tasks listeningExecutorService . shutdownNow ( ) ; // wait for cancelled tasks to terminate if ( ! listeningExecutorService . awaitTermination ( 60 , TimeUnit . SECONDS ) ) { logger . error ( "some tasks did not terminate" ) ; } } } catch ( InterruptedException e ) { listeningExecutorService . shutdownNow ( ) ; Thread . currentThread ( ) . interrupt ( ) ; } }


Input: Initializes { [CODESPLIT] private void initialize ( ) throws DocumentClientException { logger . debug ( "Initializing ..." ) ; this . bulkImportStoredProcLink = String . format ( "%s/sprocs/%s" , collectionLink , BULK_IMPORT_STORED_PROCECURE_NAME ) ; logger . trace ( "Fetching partition map of collection" ) ; Range < String > fullRange = new Range < String > ( PartitionKeyInternal . MinimumInclusiveEffectivePartitionKey , PartitionKeyInternal . MaximumExclusiveEffectivePartitionKey , true , false ) ; this . collectionRoutingMap = getCollectionRoutingMap ( client ) ; Collection < PartitionKeyRange > partitionKeyRanges = this . collectionRoutingMap . getOverlappingRanges ( fullRange ) ; this . partitionKeyRangeIds = partitionKeyRanges . stream ( ) . map ( partitionKeyRange -> partitionKeyRange . getId ( ) ) . collect ( Collectors . toList ( ) ) ; logger . debug ( "Initialization completed" ) ; }


Input: Executes a bulk import in the Azure Cosmos DB database service . <blockquote > <pre > { @code ConnectionPolicy connectionPolicy = new ConnectionPolicy () ; RetryOptions retryOptions = new RetryOptions () ; // set to 0 to let bulk importer handles throttling retryOptions . setMaxRetryAttemptsOnThrottledRequests ( 0 ) ; connectionPolicy . setRetryOptions ( retryOptions ) ; connectionPolicy . setMaxPoolSize ( 200 ) ; [CODESPLIT] public BulkImportResponse importAll ( Collection < String > documents , boolean isUpsert ) throws DocumentClientException { return executeBulkImportInternal ( documents , isUpsert ) ; }


Input: Extracts effective { [CODESPLIT] public static PartitionKeyInternal extractPartitionKeyValue ( String documentAsString , PartitionKeyDefinition partitionKeyDefinition ) { if ( partitionKeyDefinition == null || partitionKeyDefinition . getPaths ( ) . size ( ) == 0 ) { return PartitionKeyInternal . getEmpty ( ) ; } return DocumentAnalyzer . extractPartitionKeyValueInternal ( documentAsString , partitionKeyDefinition ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean abort ( ) throws LoginException { log . trace ( "In abort()" ) ; for ( YubikeyPrincipal p : this . principals ) { this . subject . getPrincipals ( ) . remove ( p ) ; } return true ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean commit ( ) throws LoginException { log . trace ( "In commit()" ) ; for ( YubikeyPrincipal p : this . principals ) { log . debug ( "Committing principal {}" , p ) ; this . subject . getPrincipals ( ) . add ( p ) ; } return true ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean logout ( ) throws LoginException { log . trace ( "In logout()" ) ; for ( YubikeyPrincipal p : this . principals ) { this . subject . getPrincipals ( ) . remove ( p ) ; } return false ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void initialize ( Subject newSubject , CallbackHandler newCallbackHandler , Map < String , ? > sharedState , Map < String , ? > options ) { log . debug ( "Initializing YubikeyLoginModule" ) ; this . subject = newSubject ; this . callbackHandler = newCallbackHandler ; /* Yubico verification client */ Integer clientId = Integer . parseInt ( options . get ( OPTION_YUBICO_CLIENT_ID ) . toString ( ) ) ; String clientKey = options . get ( OPTION_YUBICO_CLIENT_KEY ) . toString ( ) ; this . yc = YubicoClient . getClient ( clientId , clientKey ) ; /* Realm of principals added after authentication */ if ( options . containsKey ( OPTION_YUBICO_ID_REALM ) ) { this . idRealm = options . get ( OPTION_YUBICO_ID_REALM ) . toString ( ) ; } /* Should this JAAS module be ignored when no OTPs are supplied? */ if ( options . containsKey ( OPTION_YUBICO_SOFT_FAIL_NO_OTPS ) ) { if ( "true" . equals ( options . get ( OPTION_YUBICO_SOFT_FAIL_NO_OTPS ) . toString ( ) ) ) { this . soft_fail_on_no_otps = true ; } } /* Should this JAAS module uses j_otp form to pick up otp */ if ( options . containsKey ( OPTION_YUBICO_JACC ) ) { if ( "true" . equals ( options . get ( OPTION_YUBICO_JACC ) . toString ( ) ) ) { this . jacc = true ; } } /* User-provided URLs to the Yubico validation service, separated by "|". */ if ( options . containsKey ( OPTION_YUBICO_WSAPI_URLS ) ) { String in = options . get ( OPTION_YUBICO_WSAPI_URLS ) . toString ( ) ; String l [ ] = in . split ( "\\|" ) ; this . yc . setWsapiUrls ( l ) ; } if ( options . containsKey ( OPTION_YUBICO_SYNC_POLICY ) ) { this . yc . setSync ( Integer . parseInt ( options . get ( OPTION_YUBICO_SYNC_POLICY ) . toString ( ) ) ) ; } /* Instantiate the specified usermap implementation. */ String usermap_class_name = null ; if ( options . containsKey ( OPTION_YUBICO_USERMAP_CLASS ) ) { usermap_class_name = options . get ( OPTION_YUBICO_USERMAP_CLASS ) . toString ( ) ; } else { usermap_class_name = "com.yubico.jaas.impl.YubikeyToUserMapImpl" ; // Default implementation } try { log . debug ( "Trying to instantiate {}" , usermap_class_name ) ; this . ykmap = ( YubikeyToUserMap ) Class . forName ( usermap_class_name ) . newInstance ( ) ; this . ykmap . setOptions ( options ) ; } catch ( ClassNotFoundException ex ) { log . error ( "Could not create usermap from class " + usermap_class_name , ex ) ; } catch ( InstantiationException ex ) { log . error ( "Could not create usermap from class " + usermap_class_name , ex ) ; } catch ( IllegalAccessException ex ) { log . error ( "Could not create usermap from class " + usermap_class_name , ex ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean login ( ) throws LoginException { NameCallback nameCb = new NameCallback ( "Enter username: " ) ; log . debug ( "Begin OTP login" ) ; if ( callbackHandler == null ) { throw new LoginException ( "No callback handler available in login()" ) ; } List < String > otps = get_tokens ( nameCb ) ; if ( otps . size ( ) == 0 ) { if ( this . soft_fail_on_no_otps ) { log . debug ( "No OTPs found, and soft-fail is on. Making JAAS ignore this module." ) ; return false ; } throw new LoginException ( "YubiKey OTP authentication failed - no OTPs supplied" ) ; } if ( validate_otps ( otps , nameCb ) ) { return true ; } log . info ( "None out of {} possible YubiKey OTPs for user {} validated successful" , otps . size ( ) , nameCb . getName ( ) ) ; throw new LoginException ( "YubiKey OTP authentication failed" ) ; }


Input:
Try to validate all the OTPs provided . [CODESPLIT] private boolean validate_otps ( List < String > otps , NameCallback nameCb ) throws LoginException { boolean validated = false ; for ( String otp : otps ) { log . trace ( "Checking OTP {}" , otp ) ; VerificationResponse ykr ; try { ykr = this . yc . verify ( otp ) ; } catch ( YubicoVerificationException e ) { log . warn ( "Errors during validation: " , e ) ; throw new LoginException ( "Errors during validation: " + e . getMessage ( ) ) ; } catch ( YubicoValidationFailure e ) { log . warn ( "Something went very wrong during authentication: " , e ) ; throw new LoginException ( "Something went very wrong during authentication: " + e . getMessage ( ) ) ; } if ( ykr != null ) { log . trace ( "OTP {} verify result : {}" , otp , ykr . getStatus ( ) . toString ( ) ) ; if ( ykr . getStatus ( ) == ResponseStatus . OK ) { String publicId = YubicoClient . getPublicId ( otp ) ; log . info ( "OTP verified successfully (YubiKey id {})" , publicId ) ; if ( is_right_user ( nameCb . getName ( ) , publicId ) ) { this . principals . add ( new YubikeyPrincipal ( publicId , this . idRealm ) ) ; /* Don't just return here, we want to "consume" all OTPs if
						 * more than one is provided.
						 */ validated = true ; } } else { log . debug ( "OTP validation returned {}" , ykr . getStatus ( ) . toString ( ) ) ; } } } return validated ; }


Input: After validation of an OTP check that it came from a YubiKey that actually belongs to the user trying to authenticate . [CODESPLIT] private boolean is_right_user ( String username , String publicId ) { log . debug ( "Check if YubiKey {} belongs to user {}" , publicId , username ) ; return this . ykmap . is_right_user ( username , publicId ) ; }


Input:
Get username and token ( s ) from the application using the javax . security . auth . callback . CallbackHandler passed to our initialize () function . [CODESPLIT] private List < String > get_tokens ( NameCallback nameCb ) { MultiValuePasswordCallback mv_passCb = new MultiValuePasswordCallback ( "Enter authentication tokens: " , false ) ; List < String > result = new ArrayList < String > ( ) ; try { /* Fetch a password using the callbackHandler */ callbackHandler . handle ( new Callback [ ] { nameCb , mv_passCb } ) ; for ( char [ ] c : mv_passCb . getSecrets ( ) ) { String s = new String ( c ) ; /* Check that OTP is at least 32 chars before we verify it. User might have entered
				 * some other password instead of an OTP, and we don't want to send that, possibly
				 * in clear text, over the network.
				 */ if ( s . length ( ) < 32 ) { log . debug ( "Skipping token, not a valid YubiKey OTP (too short, {} < 32)" , s . length ( ) ) ; } else { result . add ( s ) ; } } } catch ( UnsupportedCallbackException ex ) { log . error ( "Callback type not supported" , ex ) ; } catch ( IOException ex ) { log . error ( "CallbackHandler failed" , ex ) ; } if ( jacc ) { // This is JACC specific mechanism try { HttpServletRequest request = ( HttpServletRequest ) PolicyContext . getContext ( JACC_ATTR_WEB_REQUEST_KEY ) ; String j_otp = request . getParameter ( HTTP_REQUEST_ATTR_TOTP ) ; if ( j_otp == null || j_otp . length ( ) < 32 ) { log . debug ( "Skipping token from j_otp, not a valid YubiKey OTP (too short, {} < 32)" , j_otp == null ? 0 : j_otp . length ( ) ) ; } else { result . add ( j_otp ) ; } log . debug ( "OTP from j_otp token : {}" , j_otp ) ; } catch ( PolicyContextException e ) { log . debug ( "No OTP from j_otp token)" ) ; } } return result ; }


Input: { [CODESPLIT] public final void setOptions ( Map < String , ? > options ) { /* Is verification of YubiKey owners enabled? */ this . verify_yubikey_owner = true ; if ( options . get ( OPTION_YUBICO_VERIFY_YK_OWNER ) != null ) { if ( "false" . equals ( options . get ( OPTION_YUBICO_VERIFY_YK_OWNER ) . toString ( ) ) ) { this . verify_yubikey_owner = false ; } } /* id2name text file */ if ( options . get ( OPTION_YUBICO_ID2NAME_TEXTFILE ) != null ) { this . id2name_textfile = options . get ( OPTION_YUBICO_ID2NAME_TEXTFILE ) . toString ( ) ; } /* should we automatically assign new yubikeys to users? */ if ( options . get ( OPTION_YUBICO_AUTO_PROVISION ) != null ) { if ( "true" . equals ( options . get ( OPTION_YUBICO_AUTO_PROVISION ) . toString ( ) ) ) { this . auto_provision_owners = true ; } } }


Input: { [CODESPLIT] public boolean is_right_user ( String username , String publicId ) { if ( ! this . verify_yubikey_owner ) { log . debug ( "YubiKey owner verification disabled, returning 'true'" ) ; return true ; } if ( this . id2name_textfile == null ) { log . debug ( "No id2name configuration. Defaulting to {}." , this . verify_yubikey_owner ) ; return this . verify_yubikey_owner ; } String ykuser ; try { ykuser = get_username_for_id ( publicId , this . id2name_textfile ) ; } catch ( FileNotFoundException ex ) { log . error ( "Yubikey to username textfile {} not found" , this . id2name_textfile ) ; return false ; } if ( ykuser != null ) { if ( ! ykuser . equals ( username ) ) { log . info ( "YubiKey " + publicId + " registered to user {}, NOT {}" , ykuser , username ) ; return false ; } return true ; } else { if ( this . auto_provision_owners ) { log . info ( "Registering new YubiKey " + publicId + " as belonging to {}" , username ) ; add_yubikey_to_user ( publicId , username , this . id2name_textfile ) ; return true ; } log . debug ( "No record of YubiKey {} found. Returning 'false'." , publicId ) ; return false ; } }


Input: Given publicId vvcccccfhc scans filename for a line like yk . vvcccccfhc . user = alice and returns alice if found . Null is returned in case there is no matching line in file . [CODESPLIT] private String get_username_for_id ( String publicId , String filename ) throws FileNotFoundException { Scanner sc = null ; File file = new File ( filename ) ; try { sc = new Scanner ( file ) ; while ( sc . hasNextLine ( ) ) { String line = sc . nextLine ( ) ; if ( line . startsWith ( "yk." + publicId + ".user" ) ) { String ykuser = line . split ( "=" ) [ 1 ] . trim ( ) ; return ykuser ; } } } finally { if ( sc != null ) { sc . close ( ) ; } } return null ; }


Input: Stores an association between username and YubiKey publicId in filename . [CODESPLIT] private void add_yubikey_to_user ( String publicId , String username , String filename ) { try { File file = new File ( filename ) ; FileWriter writer = new FileWriter ( file , true ) ; writer . write ( "yk." + publicId + ".user = " + username + System . getProperty ( "line.separator" ) ) ; writer . close ( ) ; } catch ( IOException ex ) { log . error ( "Failed appending entry to file {}" , filename , ex ) ; } }


Input: { [CODESPLIT] public VerificationResponse verify ( String otp ) throws YubicoVerificationException , YubicoValidationFailure { if ( ! isValidOTPFormat ( otp ) ) { throw new IllegalArgumentException ( "The OTP is not a valid format" ) ; } Map < String , String > requestMap = new TreeMap < String , String > ( ) ; String nonce = UUID . randomUUID ( ) . toString ( ) . replaceAll ( "-" , "" ) ; requestMap . put ( "nonce" , nonce ) ; requestMap . put ( "id" , clientId . toString ( ) ) ; requestMap . put ( "otp" , otp ) ; requestMap . put ( "timestamp" , "1" ) ; if ( sync != null ) { requestMap . put ( "sl" , sync . toString ( ) ) ; } String queryString ; try { queryString = toQueryString ( requestMap ) ; } catch ( UnsupportedEncodingException e ) { throw new YubicoVerificationException ( "Failed to encode parameter." , e ) ; } if ( key != null ) { queryString = sign ( queryString ) ; } String [ ] wsapiUrls = this . getWsapiUrls ( ) ; List < String > validationUrls = new ArrayList < String > ( ) ; for ( String wsapiUrl : wsapiUrls ) { warnIfDeprecatedUrl ( wsapiUrl ) ; validationUrls . add ( wsapiUrl + "?" + queryString ) ; } VerificationResponse response = validationService . fetch ( validationUrls , userAgent ) ; if ( key != null ) { verifySignature ( response ) ; } // NONCE/OTP fields are not returned to the client when sending error codes. // If there is an error response, don't need to check them. if ( ! response . getStatus ( ) . isError ( ) ) { if ( response . getOtp ( ) == null || ! otp . equals ( response . getOtp ( ) ) ) { throw new YubicoValidationFailure ( "OTP mismatch in response, is there a man-in-the-middle?" ) ; } if ( response . getNonce ( ) == null || ! nonce . equals ( response . getNonce ( ) ) ) { throw new YubicoValidationFailure ( "Nonce mismatch in response, is there a man-in-the-middle?" ) ; } } return response ; }


Input: { [CODESPLIT] public boolean is_right_user ( String username , String publicId ) { log . trace ( "In is_right_user()" ) ; if ( ! this . verify_yubikey_owner ) { log . debug ( "YubiKey owner verification disabled, returning 'true'" ) ; return true ; } String ykuser = null ; try { SearchFilter filter = new SearchFilter ( "({0}={1})" , new String [ ] { this . publicid_attribute , publicId } ) ; log . debug ( "Searching for YubiKey publicId with filter: {}" , filter . toString ( ) ) ; Iterator < SearchResult > results = ldap . search ( filter , new String [ ] { this . username_attribute } ) ; if ( results . hasNext ( ) ) { Attributes results_attributes = results . next ( ) . getAttributes ( ) ; log . debug ( "Found attributes: {}" , results_attributes . toString ( ) ) ; ykuser = results_attributes . get ( this . username_attribute ) . get ( ) . toString ( ) ; } else { log . debug ( "No search results" ) ; } } catch ( NamingException ex ) { log . error ( ex . getMessage ( ) , ex ) ; return false ; } if ( ykuser != null ) { if ( ! ykuser . equals ( username ) ) { log . info ( "YubiKey " + publicId + " registered to user {}, NOT {}" , ykuser , username ) ; return false ; } else { log . info ( "YubiKey " + publicId + " registered to user {}" , ykuser ) ; return true ; } } else { log . info ( "No record of YubiKey {} found. Returning 'false'." , publicId ) ; return false ; } }


Input: { [CODESPLIT] public final void setOptions ( Map < String , ? > options ) { /* Is verification of YubiKey owners enabled? */ this . verify_yubikey_owner = true ; if ( options . get ( OPTION_YUBICO_VERIFY_YK_OWNER ) != null ) { if ( "false" . equals ( options . get ( OPTION_YUBICO_VERIFY_YK_OWNER ) . toString ( ) ) ) { this . verify_yubikey_owner = false ; } } if ( options . get ( OPTION_YUBICO_LDAP_PUBLICID_ATTRIBUTE ) != null ) { this . publicid_attribute = options . get ( OPTION_YUBICO_LDAP_PUBLICID_ATTRIBUTE ) . toString ( ) ; } if ( options . get ( OPTION_YUBICO_LDAP_USERNAME_ATTRIBUTE ) != null ) { this . username_attribute = options . get ( OPTION_YUBICO_LDAP_USERNAME_ATTRIBUTE ) . toString ( ) ; } if ( options . get ( OPTION_LDAP_URL ) != null ) { this . ldap_url = options . get ( OPTION_LDAP_URL ) . toString ( ) ; } if ( options . get ( OPTION_LDAP_BASE_DN ) != null ) { this . ldap_base_dn = options . get ( OPTION_LDAP_BASE_DN ) . toString ( ) ; } if ( options . get ( OPTION_LDAP_BIND_DN ) != null ) { this . ldap_bind_dn = options . get ( OPTION_LDAP_BIND_DN ) . toString ( ) ; } if ( options . get ( OPTION_LDAP_BIND_CREDENTIAL ) != null ) { this . ldap_bind_credential = options . get ( OPTION_LDAP_BIND_CREDENTIAL ) . toString ( ) ; } LdapConfig config = new LdapConfig ( this . ldap_url , this . ldap_base_dn ) ; config . setBindDn ( this . ldap_bind_dn ) ; config . setBindCredential ( this . ldap_bind_credential ) ; this . ldap = new Ldap ( config ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void initialize ( Subject newSubject , CallbackHandler newCallbackHandler , Map < String , ? > sharedState , Map < String , ? > options ) { log . trace ( "Initializing HTTP OATH OTP LoginModule" ) ; this . subject = newSubject ; this . callbackHandler = newCallbackHandler ; this . protectedUrl = options . get ( OPTION_HTTPOATHOTP_PROTECTED_URL ) . toString ( ) ; if ( options . get ( OPTION_HTTPOATHOTP_EXPECTED_OUTPUT ) != null ) { this . expectedOutput = options . get ( OPTION_HTTPOATHOTP_EXPECTED_OUTPUT ) . toString ( ) ; } if ( options . get ( OPTION_HTTPOATHOTP_MIN_LENGTH ) != null ) { this . minLength = Integer . parseInt ( options . get ( OPTION_HTTPOATHOTP_MIN_LENGTH ) . toString ( ) ) ; } if ( options . get ( OPTION_HTTPOATHOTP_MAX_LENGTH ) != null ) { this . maxLength = Integer . parseInt ( options . get ( OPTION_HTTPOATHOTP_MAX_LENGTH ) . toString ( ) ) ; } if ( options . get ( OPTION_HTTPOATHOTP_REQUIRE_ALL_DIGITS ) != null ) { String s = options . get ( OPTION_HTTPOATHOTP_REQUIRE_ALL_DIGITS ) . toString ( ) ; if ( s . equals ( "true" ) ) { this . requireAllDigits = true ; } else if ( s . equals ( "false" ) ) { this . requireAllDigits = false ; } else { log . error ( "Bad value for option {}" , OPTION_HTTPOATHOTP_REQUIRE_ALL_DIGITS ) ; } } /* Realm of principals added after authentication */ if ( options . get ( OPTION_HTTPOATHOTP_ID_REALM ) != null ) { this . idRealm = options . get ( OPTION_HTTPOATHOTP_ID_REALM ) . toString ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean login ( ) throws LoginException { log . trace ( "Begin OATH OTP login" ) ; if ( callbackHandler == null ) { throw new LoginException ( "No callback handler available in login()" ) ; } NameCallback nameCb = new NameCallback ( "Enter username: " ) ; List < String > otps = get_tokens ( nameCb ) ; for ( String otp : otps ) { String userName = nameCb . getName ( ) ; log . trace ( "Checking OATH OTP for user {}" , userName ) ; if ( verify_otp ( userName , otp ) ) { log . info ( "OATH OTP verified successfully" ) ; principal = new YubikeyPrincipal ( userName , this . idRealm ) ; return true ; } log . info ( "OATH OTP did NOT verify" ) ; } throw new LoginException ( "OATH OTP verification failed" ) ; }


Input: Access protectedUrl using userName and otp for basic auth . Check if what we get back contains expectedOutput . [CODESPLIT] boolean verify_otp ( String userName , String otp ) { try { String authString = userName + ":" + otp ; String authStringEnc = Base64 . encodeBase64URLSafeString ( authString . getBytes ( ) ) ; BufferedReader in = attemptAuthentication ( authStringEnc ) ; String inputLine ; while ( ( inputLine = in . readLine ( ) ) != null ) { if ( inputLine . contains ( expectedOutput ) ) { return true ; } } } catch ( Exception ex ) { log . error ( "Failed verifying OATH OTP :" , ex ) ; } return false ; }


Input: Tries to clear all the passwords from memory . [CODESPLIT] public void clearPassword ( ) { for ( char pw [ ] : this . secrets ) { for ( int i = 0 ; i < pw . length ; i ++ ) { pw [ i ] = 0 ; } } /* Now discard the list. */ this . secrets = new ArrayList < char [ ] > ( ) ; }


Input:
Fires off a validation request to each url in the list returning the first one that is not { @link ResponseStatus#REPLAYED_REQUEST } [CODESPLIT] public VerificationResponse fetch ( List < String > urls , String userAgent ) throws YubicoVerificationException { List < Future < VerificationResponse >> tasks = new ArrayList < Future < VerificationResponse > > ( ) ; for ( String url : urls ) { tasks . add ( completionService . submit ( createTask ( userAgent , url ) ) ) ; } VerificationResponse response = null ; try { int tasksDone = 0 ; Throwable savedException = null ; Future < VerificationResponse > futureResponse = completionService . poll ( 1L , MINUTES ) ; while ( futureResponse != null ) { try { tasksDone ++ ; tasks . remove ( futureResponse ) ; response = futureResponse . get ( ) ; /**
					 * If the response returned is REPLAYED_REQUEST keep looking at responses
					 * and hope we get something else. REPLAYED_REQUEST will be returned if a
					 * validation server got sync before it parsed our query (otp and nonce is
					 * the same).
					 * @see https://forum.yubico.com/viewtopic21be.html
					 *
					 * Also if the response is BACKEND_ERROR, keep looking for a server that
					 * sends a valid response
					 * @see https://github.com/Yubico/yubico-java-client/issues/12
					 */ if ( ! response . getStatus ( ) . equals ( REPLAYED_REQUEST ) && ! response . getStatus ( ) . equals ( BACKEND_ERROR ) ) { break ; } } catch ( CancellationException ignored ) { // this would be thrown by old cancelled calls. tasksDone -- ; } catch ( ExecutionException e ) { // tuck the real exception away and use it if we don't get any valid answers. savedException = e . getCause ( ) ; } if ( tasksDone >= urls . size ( ) ) { break ; } futureResponse = completionService . poll ( 1L , MINUTES ) ; } if ( futureResponse == null || response == null ) { if ( savedException != null ) { throw new YubicoVerificationException ( "Exception while executing validation." , savedException ) ; } else { throw new YubicoVerificationException ( "Validation timeout." ) ; } } } catch ( InterruptedException e ) { throw new YubicoVerificationException ( "Validation interrupted." , e ) ; } for ( Future < VerificationResponse > task : tasks ) { task . cancel ( true ) ; } return response ; }


Input: Configure what URLs to use for validating OTPs . These URLs will have all the necessary parameters appended to them . Example : { https : // api . yubico . com / wsapi / 2 . 0 / verify } [CODESPLIT] public void setWsapiUrls ( String [ ] wsapi ) { for ( String url : wsapi ) { warnIfDeprecatedUrl ( url ) ; } this . wsapi_urls = wsapi ; }


Input:
Extract the public ID of a YubiKey from an OTP it generated . [CODESPLIT] public static String getPublicId ( String otp ) { if ( ( otp == null ) || ( otp . length ( ) < OTP_MIN_LEN ) ) { //not a valid OTP format, throw an exception throw new IllegalArgumentException ( "The OTP is too short to be valid" ) ; } Integer len = otp . length ( ) ; /* The OTP part is always the last 32 bytes of otp. Whatever is before that
		 * (if anything) is the public ID of the YubiKey. The ID can be set to ''
		 * through personalization.
		 */ return otp . substring ( 0 , len - 32 ) . toLowerCase ( ) ; }


Input: Determines whether a given OTP is of the correct length and only contains printable characters as per the recommendation . [CODESPLIT] public static boolean isValidOTPFormat ( String otp ) { if ( otp == null ) { return false ; } int len = otp . length ( ) ; for ( char c : otp . toCharArray ( ) ) { if ( c < 0x20 || c > 0x7E ) { return false ; } } return OTP_MIN_LEN <= len && len <= OTP_MAX_LEN ; }


Input: Returns an Evaluation that contains the node source and whether it is a set operation . If there are no Evaluation objects in the pool one is created and returned . [CODESPLIT] public Evaluation create ( SimpleNode node , Object source ) { return create ( node , source , false ) ; }


Input: Returns an Evaluation that contains the node source and whether it is a set operation . [CODESPLIT] public Evaluation create ( SimpleNode node , Object source , boolean setOperation ) { // synchronization is removed as we do not rely anymore on the in-house object pooling return new Evaluation ( node , source , setOperation ) ; }


Input: Returns true if this property is described by an IndexedPropertyDescriptor and that if followed by an index specifier it will call the index get / set methods rather than go through property accessors . [CODESPLIT] public int getIndexedPropertyType ( OgnlContext context , Object source ) throws OgnlException { Class type = context . getCurrentType ( ) ; Class prevType = context . getPreviousType ( ) ; try { if ( ! isIndexedAccess ( ) ) { Object property = getProperty ( context , source ) ; if ( property instanceof String ) { return OgnlRuntime . getIndexedPropertyType ( context , ( source == null ) ? null : OgnlRuntime . getCompiler ( ) . getInterfaceClass ( source . getClass ( ) ) , ( String ) property ) ; } } return OgnlRuntime . INDEXED_PROPERTY_NONE ; } finally { context . setCurrentObject ( source ) ; context . setCurrentType ( type ) ; context . setPreviousType ( prevType ) ; } }


Input: / * MethodAccessor interface [CODESPLIT] public Object callStaticMethod ( Map context , Class targetClass , String methodName , Object [ ] args ) throws MethodFailedException { List methods = OgnlRuntime . getMethods ( targetClass , methodName , true ) ; return OgnlRuntime . callAppropriateMethod ( ( OgnlContext ) context , targetClass , null , methodName , null , methods , args ) ; }


Input: Clears all of the cached reflection information normally used to improve the speed of expressions that operate on the same classes or are executed multiple times . [CODESPLIT] public static void clearCache ( ) { _methodParameterTypesCache . clear ( ) ; _ctorParameterTypesCache . clear ( ) ; _propertyDescriptorCache . clear ( ) ; _constructorCache . clear ( ) ; _staticMethodCache . clear ( ) ; _instanceMethodCache . clear ( ) ; _invokePermissionCache . clear ( ) ; _fieldCache . clear ( ) ; _superclasses . clear ( ) ; _declaredMethods [ 0 ] . clear ( ) ; _declaredMethods [ 1 ] . clear ( ) ; _methodAccessCache . clear ( ) ; _methodPermCache . clear ( ) ; }


Input: Checks if the current jvm is java language > = 1 . 5 compatible . [CODESPLIT] public static boolean isJdk15 ( ) { if ( _jdkChecked ) return _jdk15 ; try { Class . forName ( "java.lang.annotation.Annotation" ) ; _jdk15 = true ; } catch ( Exception e ) { /* ignore */ } _jdkChecked = true ; return _jdk15 ; }


Input: Gets the target class of an object for looking up accessors that are registered on the target . If the object is a Class object this will return the Class itself else it will return object s getClass () result . [CODESPLIT] public static Class getTargetClass ( Object o ) { return ( o == null ) ? null : ( ( o instanceof Class ) ? ( Class ) o : o . getClass ( ) ) ; }


Input: Returns the base name ( the class name without the package name prepended ) of the object given . [CODESPLIT] public static String getBaseName ( Object o ) { return ( o == null ) ? null : getClassBaseName ( o . getClass ( ) ) ; }


Input: Returns the base name ( the class name without the package name prepended ) of the class given . [CODESPLIT] public static String getClassBaseName ( Class c ) { String s = c . getName ( ) ; return s . substring ( s . lastIndexOf ( ' ' ) + 1 ) ; }


Input: Returns the package name of the object s class . [CODESPLIT] public static String getPackageName ( Object o ) { return ( o == null ) ? null : getClassPackageName ( o . getClass ( ) ) ; }


Input: Returns the package name of the class given . [CODESPLIT] public static String getClassPackageName ( Class c ) { String s = c . getName ( ) ; int i = s . lastIndexOf ( ' ' ) ; return ( i < 0 ) ? null : s . substring ( 0 , i ) ; }


Input: Returns a pointer string in the usual format for these things - 0x<hex digits > . [CODESPLIT] public static String getPointerString ( int num ) { StringBuffer result = new StringBuffer ( ) ; String hex = Integer . toHexString ( num ) , pad ; Integer l = new Integer ( hex . length ( ) ) ; // result.append(HEX_PREFIX); if ( ( pad = ( String ) HEX_PADDING . get ( l ) ) == null ) { StringBuffer pb = new StringBuffer ( ) ; for ( int i = hex . length ( ) ; i < HEX_LENGTH ; i ++ ) { pb . append ( ' ' ) ; } pad = new String ( pb ) ; HEX_PADDING . put ( l , pad ) ; } result . append ( pad ) ; result . append ( hex ) ; return new String ( result ) ; }


Input: Returns a pointer string in the usual format for these things - 0x<hex digits > for the object given . This will always return a unique value for each object . [CODESPLIT] public static String getPointerString ( Object o ) { return getPointerString ( ( o == null ) ? 0 : System . identityHashCode ( o ) ) ; }


Input: Returns a unique descriptor string that includes the object s class and a unique integer identifier . If fullyQualified is true then the class name will be fully qualified to include the package name else it will be just the class base name . [CODESPLIT] public static String getUniqueDescriptor ( Object object , boolean fullyQualified ) { StringBuffer result = new StringBuffer ( ) ; if ( object != null ) { if ( object instanceof Proxy ) { Class interfaceClass = object . getClass ( ) . getInterfaces ( ) [ 0 ] ; result . append ( getClassName ( interfaceClass , fullyQualified ) ) ; result . append ( ' ' ) ; object = Proxy . getInvocationHandler ( object ) ; } result . append ( getClassName ( object , fullyQualified ) ) ; result . append ( ' ' ) ; result . append ( getPointerString ( object ) ) ; } else { result . append ( NULL_OBJECT_STRING ) ; } return new String ( result ) ; }


Input: Utility to convert a List into an Object [] array . If the list is zero elements this will return a constant array ; toArray () on List always returns a new object and this is wasteful for our purposes . [CODESPLIT] public static Object [ ] toArray ( List list ) { Object [ ] result ; int size = list . size ( ) ; if ( size == 0 ) { result = NoArguments ; } else { result = getObjectArrayPool ( ) . create ( list . size ( ) ) ; for ( int i = 0 ; i < size ; i ++ ) { result [ i ] = list . get ( i ) ; } } return result ; }


Input: Returns the parameter types of the given method . [CODESPLIT] public static Class [ ] getParameterTypes ( Method m ) { synchronized ( _methodParameterTypesCache ) { Class [ ] result ; if ( ( result = ( Class [ ] ) _methodParameterTypesCache . get ( m ) ) == null ) { _methodParameterTypesCache . put ( m , result = m . getParameterTypes ( ) ) ; } return result ; } }


Input: Finds the appropriate parameter types for the given { @link Method } and { @link Class } instance of the type the method is associated with . Correctly finds generic types if running in > = 1 . 5 jre as well . [CODESPLIT] public static Class [ ] findParameterTypes ( Class type , Method m ) { Type [ ] genTypes = m . getGenericParameterTypes ( ) ; Class [ ] types = new Class [ genTypes . length ] ; ; boolean noGenericParameter = true ; for ( int i = 0 ; i < genTypes . length ; i ++ ) { if ( Class . class . isInstance ( genTypes [ i ] ) ) { types [ i ] = ( Class ) genTypes [ i ] ; continue ; } noGenericParameter = false ; break ; } if ( noGenericParameter ) { return types ; } if ( type == null || ! isJdk15 ( ) ) { return getParameterTypes ( m ) ; } final Type typeGenericSuperclass = type . getGenericSuperclass ( ) ; if ( typeGenericSuperclass == null || ! ParameterizedType . class . isInstance ( typeGenericSuperclass ) || m . getDeclaringClass ( ) . getTypeParameters ( ) == null ) { return getParameterTypes ( m ) ; } if ( ( types = ( Class [ ] ) _genericMethodParameterTypesCache . get ( m ) ) != null ) { ParameterizedType genericSuperclass = ( ParameterizedType ) typeGenericSuperclass ; if ( Arrays . equals ( types , genericSuperclass . getActualTypeArguments ( ) ) ) { return types ; } } ParameterizedType param = ( ParameterizedType ) typeGenericSuperclass ; TypeVariable [ ] declaredTypes = m . getDeclaringClass ( ) . getTypeParameters ( ) ; types = new Class [ genTypes . length ] ; for ( int i = 0 ; i < genTypes . length ; i ++ ) { TypeVariable paramType = null ; if ( TypeVariable . class . isInstance ( genTypes [ i ] ) ) { paramType = ( TypeVariable ) genTypes [ i ] ; } else if ( GenericArrayType . class . isInstance ( genTypes [ i ] ) ) { paramType = ( TypeVariable ) ( ( GenericArrayType ) genTypes [ i ] ) . getGenericComponentType ( ) ; } else if ( ParameterizedType . class . isInstance ( genTypes [ i ] ) ) { types [ i ] = ( Class ) ( ( ParameterizedType ) genTypes [ i ] ) . getRawType ( ) ; continue ; } else if ( Class . class . isInstance ( genTypes [ i ] ) ) { types [ i ] = ( Class ) genTypes [ i ] ; continue ; } Class resolved = resolveType ( param , paramType , declaredTypes ) ; if ( resolved != null ) { if ( GenericArrayType . class . isInstance ( genTypes [ i ] ) ) { resolved = Array . newInstance ( resolved , 0 ) . getClass ( ) ; } types [ i ] = resolved ; continue ; } types [ i ] = m . getParameterTypes ( ) [ i ] ; } synchronized ( _genericMethodParameterTypesCache ) { _genericMethodParameterTypesCache . put ( m , types ) ; } return types ; }


Input: Returns the parameter types of the given method . [CODESPLIT] public static Class [ ] getParameterTypes ( Constructor c ) { Class [ ] result ; if ( ( result = ( Class [ ] ) _ctorParameterTypesCache . get ( c ) ) == null ) { synchronized ( _ctorParameterTypesCache ) { if ( ( result = ( Class [ ] ) _ctorParameterTypesCache . get ( c ) ) == null ) { _ctorParameterTypesCache . put ( c , result = c . getParameterTypes ( ) ) ; } } } return result ; }


Input: Permission will be named invoke . <declaring - class > . <method - name > . [CODESPLIT] public static Permission getPermission ( Method method ) { Permission result ; Class mc = method . getDeclaringClass ( ) ; synchronized ( _invokePermissionCache ) { Map permissions = ( Map ) _invokePermissionCache . get ( mc ) ; if ( permissions == null ) { _invokePermissionCache . put ( mc , permissions = new HashMap ( 101 ) ) ; } if ( ( result = ( Permission ) permissions . get ( method . getName ( ) ) ) == null ) { result = new OgnlInvokePermission ( "invoke." + mc . getName ( ) + "." + method . getName ( ) ) ; permissions . put ( method . getName ( ) , result ) ; } } return result ; }


Input: Gets the class for a method argument that is appropriate for looking up methods by reflection by looking for the standard primitive wrapper classes and exchanging for them their underlying primitive class objects . Other classes are passed through unchanged . [CODESPLIT] public static final Class getArgClass ( Object arg ) { if ( arg == null ) return null ; Class c = arg . getClass ( ) ; if ( c == Boolean . class ) return Boolean . TYPE ; else if ( c . getSuperclass ( ) == Number . class ) { if ( c == Integer . class ) return Integer . TYPE ; if ( c == Double . class ) return Double . TYPE ; if ( c == Byte . class ) return Byte . TYPE ; if ( c == Long . class ) return Long . TYPE ; if ( c == Float . class ) return Float . TYPE ; if ( c == Short . class ) return Short . TYPE ; } else if ( c == Character . class ) return Character . TYPE ; return c ; }


Input: Tells whether the given object is compatible with the given class --- that is whether the given object can be passed as an argument to a method or constructor whose parameter type is the given class . If object is null this will return true because null is compatible with any type . [CODESPLIT] public static final boolean isTypeCompatible ( Object object , Class c ) { if ( object == null ) return true ; ArgsCompatbilityReport report = new ArgsCompatbilityReport ( 0 , new boolean [ 1 ] ) ; if ( ! isTypeCompatible ( getArgClass ( object ) , c , 0 , report ) ) return false ; if ( report . conversionNeeded [ 0 ] ) return false ; // we don't allow conversions during this path... return true ; }


Input: Tells whether the first array of classes is more specific than the second . Assumes that the two arrays are of the same length . [CODESPLIT] public static final boolean isMoreSpecific ( Class [ ] classes1 , Class [ ] classes2 ) { for ( int index = 0 , count = classes1 . length ; index < count ; ++ index ) { Class c1 = classes1 [ index ] , c2 = classes2 [ index ] ; if ( c1 == c2 ) continue ; else if ( c1 . isPrimitive ( ) ) return true ; else if ( c1 . isAssignableFrom ( c2 ) ) return false ; else if ( c2 . isAssignableFrom ( c1 ) ) return true ; } // They are the same! So the first is not more specific than the second. return false ; }


Input: Gets the appropriate method to be called for the given target method name and arguments . If successful this method will return the Method within the target that can be called and the converted arguments in actualArgs . If unsuccessful this method will return null and the actualArgs will be empty . [CODESPLIT] public static Method getAppropriateMethod ( OgnlContext context , Object source , Object target , String propertyName , String methodName , List methods , Object [ ] args , Object [ ] actualArgs ) { Method result = null ; if ( methods != null ) { Class typeClass = target != null ? target . getClass ( ) : null ; if ( typeClass == null && source != null && Class . class . isInstance ( source ) ) { typeClass = ( Class ) source ; } Class [ ] argClasses = getArgClasses ( args ) ; MatchingMethod mm = findBestMethod ( methods , typeClass , methodName , argClasses ) ; if ( mm != null ) { result = mm . mMethod ; Class [ ] mParameterTypes = mm . mParameterTypes ; System . arraycopy ( args , 0 , actualArgs , 0 , args . length ) ; for ( int j = 0 ; j < mParameterTypes . length ; j ++ ) { Class type = mParameterTypes [ j ] ; if ( mm . report . conversionNeeded [ j ] || ( type . isPrimitive ( ) && ( actualArgs [ j ] == null ) ) ) { actualArgs [ j ] = getConvertedType ( context , source , result , propertyName , args [ j ] , type ) ; } } } } if ( result == null ) { result = getConvertedMethodAndArgs ( context , target , propertyName , methods , args , actualArgs ) ; } return result ; }


Input: Invokes the specified method against the target object . [CODESPLIT] public static Object callMethod ( OgnlContext context , Object target , String methodName , String propertyName , Object [ ] args ) throws OgnlException { return callMethod ( context , target , methodName == null ? propertyName : methodName , args ) ; }


Input: Invokes the specified method against the target object . [CODESPLIT] public static Object callMethod ( OgnlContext context , Object target , String methodName , Object [ ] args ) throws OgnlException { if ( target == null ) throw new NullPointerException ( "target is null for method " + methodName ) ; return getMethodAccessor ( target . getClass ( ) ) . callMethod ( context , target , methodName , args ) ; }


Input: If the checkAccessAndExistence flag is true this method will check to see if the method exists and if it is accessible according to the context s MemberAccess . If neither test passes this will return NotFound . [CODESPLIT] public static final Object getMethodValue ( OgnlContext context , Object target , String propertyName , boolean checkAccessAndExistence ) throws OgnlException , IllegalAccessException , NoSuchMethodException , IntrospectionException { Object result = null ; Method m = getGetMethod ( context , ( target == null ) ? null : target . getClass ( ) , propertyName ) ; if ( m == null ) m = getReadMethod ( ( target == null ) ? null : target . getClass ( ) , propertyName , null ) ; if ( checkAccessAndExistence ) { if ( ( m == null ) || ! context . getMemberAccess ( ) . isAccessible ( context , target , m , propertyName ) ) { result = NotFound ; } } if ( result == null ) { if ( m != null ) { try { result = invokeMethod ( target , m , NoArguments ) ; } catch ( InvocationTargetException ex ) { throw new OgnlException ( propertyName , ex . getTargetException ( ) ) ; } } else { throw new NoSuchMethodException ( propertyName ) ; } } return result ; }


Input: Don t use this method as it doesn t check member access rights via { [CODESPLIT] @ Deprecated public static boolean setMethodValue ( OgnlContext context , Object target , String propertyName , Object value ) throws OgnlException , IllegalAccessException , NoSuchMethodException , IntrospectionException { return setMethodValue ( context , target , propertyName , value , false ) ; }


Input: This method returns the property descriptors for the given class as a Map . [CODESPLIT] public static Map getPropertyDescriptors ( Class targetClass ) throws IntrospectionException , OgnlException { Map result ; if ( ( result = ( Map ) _propertyDescriptorCache . get ( targetClass ) ) == null ) { synchronized ( _propertyDescriptorCache ) { if ( ( result = ( Map ) _propertyDescriptorCache . get ( targetClass ) ) == null ) { PropertyDescriptor [ ] pda = Introspector . getBeanInfo ( targetClass ) . getPropertyDescriptors ( ) ; result = new HashMap ( 101 ) ; for ( int i = 0 , icount = pda . length ; i < icount ; i ++ ) { // workaround for Introspector bug 6528714 (bugs.sun.com) if ( pda [ i ] . getReadMethod ( ) != null && ! isMethodCallable ( pda [ i ] . getReadMethod ( ) ) ) { pda [ i ] . setReadMethod ( findClosestMatchingMethod ( targetClass , pda [ i ] . getReadMethod ( ) , pda [ i ] . getName ( ) , pda [ i ] . getPropertyType ( ) , true ) ) ; } if ( pda [ i ] . getWriteMethod ( ) != null && ! isMethodCallable ( pda [ i ] . getWriteMethod ( ) ) ) { pda [ i ] . setWriteMethod ( findClosestMatchingMethod ( targetClass , pda [ i ] . getWriteMethod ( ) , pda [ i ] . getName ( ) , pda [ i ] . getPropertyType ( ) , false ) ) ; } result . put ( pda [ i ] . getName ( ) , pda [ i ] ) ; } findObjectIndexedPropertyDescriptors ( targetClass , result ) ; _propertyDescriptorCache . put ( targetClass , result ) ; } } } return result ; }


Input: This method returns a PropertyDescriptor for the given class and property name using a Map lookup ( using getPropertyDescriptorsMap () ) . [CODESPLIT] public static PropertyDescriptor getPropertyDescriptor ( Class targetClass , String propertyName ) throws IntrospectionException , OgnlException { if ( targetClass == null ) return null ; return ( PropertyDescriptor ) getPropertyDescriptors ( targetClass ) . get ( propertyName ) ; }


Input: Gets the property descriptor with the given name for the target class given . [CODESPLIT] public static PropertyDescriptor getPropertyDescriptorFromArray ( Class targetClass , String name ) throws IntrospectionException { PropertyDescriptor result = null ; PropertyDescriptor [ ] pda = getPropertyDescriptorsArray ( targetClass ) ; for ( int i = 0 , icount = pda . length ; ( result == null ) && ( i < icount ) ; i ++ ) { if ( pda [ i ] . getName ( ) . compareTo ( name ) == 0 ) { result = pda [ i ] ; } } return result ; }


Input: Determines the index property type if any . Returns <code > INDEXED_PROPERTY_NONE< / code > if the property is not index - accessible as determined by OGNL or JavaBeans . If it is indexable then this will return whether it is a JavaBeans indexed property conforming to the indexed property patterns ( returns <code > INDEXED_PROPERTY_INT< / code > ) or if it conforms to the OGNL arbitrary object indexable ( returns <code > INDEXED_PROPERTY_OBJECT< / code > ) . [CODESPLIT] public static int getIndexedPropertyType ( OgnlContext context , Class sourceClass , String name ) throws OgnlException { int result = INDEXED_PROPERTY_NONE ; try { PropertyDescriptor pd = getPropertyDescriptor ( sourceClass , name ) ; if ( pd != null ) { if ( pd instanceof IndexedPropertyDescriptor ) { result = INDEXED_PROPERTY_INT ; } else { if ( pd instanceof ObjectIndexedPropertyDescriptor ) { result = INDEXED_PROPERTY_OBJECT ; } } } } catch ( Exception ex ) { throw new OgnlException ( "problem determining if '" + name + "' is an indexed property" , ex ) ; } return result ; }


Input: Registers the specified { @link ClassCacheInspector } with all class reflection based internal caches . This may have a significant performance impact so be careful using this in production scenarios . [CODESPLIT] public static void setClassCacheInspector ( ClassCacheInspector inspector ) { _cacheInspector = inspector ; _propertyDescriptorCache . setClassInspector ( _cacheInspector ) ; _constructorCache . setClassInspector ( _cacheInspector ) ; _staticMethodCache . setClassInspector ( _cacheInspector ) ; _instanceMethodCache . setClassInspector ( _cacheInspector ) ; _invokePermissionCache . setClassInspector ( _cacheInspector ) ; _fieldCache . setClassInspector ( _cacheInspector ) ; _declaredMethods [ 0 ] . setClassInspector ( _cacheInspector ) ; _declaredMethods [ 1 ] . setClassInspector ( _cacheInspector ) ; }


Input: Finds the best possible match for a method on the specified target class with a matching name . [CODESPLIT] public static Method getReadMethod ( Class target , String name ) { return getReadMethod ( target , name , null ) ; }


Input: Compares the { @link OgnlContext#getCurrentType () } and { @link OgnlContext#getPreviousType () } class types on the stack to determine if a numeric expression should force object conversion . <p / > <p / > Normally used in conjunction with the <code > forceConversion< / code > parameter of { @link OgnlRuntime#getChildSource ( OgnlContext Object Node boolean ) } . < / p > [CODESPLIT] public static boolean shouldConvertNumericTypes ( OgnlContext context ) { if ( context . getCurrentType ( ) == null || context . getPreviousType ( ) == null ) return true ; if ( context . getCurrentType ( ) == context . getPreviousType ( ) && context . getCurrentType ( ) . isPrimitive ( ) && context . getPreviousType ( ) . isPrimitive ( ) ) return false ; return context . getCurrentType ( ) != null && ! context . getCurrentType ( ) . isArray ( ) && context . getPreviousType ( ) != null && ! context . getPreviousType ( ) . isArray ( ) ; }


Input: Attempts to get the java source string represented by the specific child expression via the { @link JavaSource#toGetSourceString ( OgnlContext Object ) } interface method . [CODESPLIT] public static String getChildSource ( OgnlContext context , Object target , Node child ) throws OgnlException { return getChildSource ( context , target , child , false ) ; }


Input: Attempts to get the java source string represented by the specific child expression via the { @link JavaSource#toGetSourceString ( OgnlContext Object ) } interface method . [CODESPLIT] public static String getChildSource ( OgnlContext context , Object target , Node child , boolean forceConversion ) throws OgnlException { String pre = ( String ) context . get ( "_currentChain" ) ; if ( pre == null ) pre = "" ; try { child . getValue ( context , target ) ; } catch ( NullPointerException e ) { // ignore } catch ( ArithmeticException e ) { context . setCurrentType ( int . class ) ; return "0" ; } catch ( Throwable t ) { throw OgnlOps . castToRuntime ( t ) ; } String source = null ; try { source = child . toGetSourceString ( context , target ) ; } catch ( Throwable t ) { throw OgnlOps . castToRuntime ( t ) ; } // handle root / method expressions that may not have proper root java source access if ( ! ASTConst . class . isInstance ( child ) && ( target == null || context . getRoot ( ) != target ) ) { source = pre + source ; } if ( context . getRoot ( ) != null ) { source = ExpressionCompiler . getRootExpression ( child , context . getRoot ( ) , context ) + source ; context . setCurrentAccessor ( context . getRoot ( ) . getClass ( ) ) ; } if ( ASTChain . class . isInstance ( child ) ) { String cast = ( String ) context . remove ( ExpressionCompiler . PRE_CAST ) ; if ( cast == null ) cast = "" ; source = cast + source ; } if ( source == null || source . trim ( ) . length ( ) < 1 ) source = "null" ; return source ; }


Input: Prints the stack trace for this ( and possibly the encapsulated ) exception on the given print stream . [CODESPLIT] public void printStackTrace ( java . io . PrintStream s ) { synchronized ( s ) { super . printStackTrace ( s ) ; if ( _reason != null ) { s . println ( "/-- Encapsulated exception ------------\\" ) ; _reason . printStackTrace ( s ) ; s . println ( "\\--------------------------------------/" ) ; } } }


Input: Prints the stack trace for this ( and possibly the encapsulated ) exception on the given print writer . [CODESPLIT] public void printStackTrace ( java . io . PrintWriter s ) { synchronized ( s ) { super . printStackTrace ( s ) ; if ( _reason != null ) { s . println ( "/-- Encapsulated exception ------------\\" ) ; _reason . printStackTrace ( s ) ; s . println ( "\\--------------------------------------/" ) ; } } }


Input: / * NullHandler interface [CODESPLIT] public Object nullMethodResult ( Map context , Object target , String methodName , Object [ ] args ) { return null ; }


Input: Read a character . [CODESPLIT] public char readChar ( ) throws java . io . IOException { if ( inBuf > 0 ) { -- inBuf ; if ( ++ bufpos == bufsize ) bufpos = 0 ; return buffer [ bufpos ] ; } char c ; if ( ++ bufpos == available ) AdjustBuffSize ( ) ; if ( ( buffer [ bufpos ] = c = ReadByte ( ) ) == ' ' ) { UpdateLineColumn ( c ) ; int backSlashCnt = 1 ; for ( ; ; ) // Read all the backslashes { if ( ++ bufpos == available ) AdjustBuffSize ( ) ; try { if ( ( buffer [ bufpos ] = c = ReadByte ( ) ) != ' ' ) { UpdateLineColumn ( c ) ; // found a non-backslash char. if ( ( c == ' ' ) && ( ( backSlashCnt & 1 ) == 1 ) ) { if ( -- bufpos < 0 ) bufpos = bufsize - 1 ; break ; } backup ( backSlashCnt ) ; return ' ' ; } } catch ( java . io . IOException e ) { if ( backSlashCnt > 1 ) backup ( backSlashCnt - 1 ) ; return ' ' ; } UpdateLineColumn ( c ) ; backSlashCnt ++ ; } // Here, we have seen an odd number of backslash's followed by a 'u' try { while ( ( c = ReadByte ( ) ) == ' ' ) ++ column ; buffer [ bufpos ] = c = ( char ) ( hexval ( c ) << 12 | hexval ( ReadByte ( ) ) << 8 | hexval ( ReadByte ( ) ) << 4 | hexval ( ReadByte ( ) ) ) ; column += 4 ; } catch ( java . io . IOException e ) { throw new Error ( "Invalid escape character at line " + line + " column " + column + "." ) ; } if ( backSlashCnt == 1 ) return c ; else { backup ( backSlashCnt - 1 ) ; return ' ' ; } } else { UpdateLineColumn ( c ) ; return c ; } }


Input: sequence ( level 14 ) [CODESPLIT] final public void expression ( ) throws ParseException { assignmentExpression ( ) ; label_1 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 1 : ; break ; default : jj_la1 [ 0 ] = jj_gen ; break label_1 ; } jj_consume_token ( 1 ) ; ASTSequence jjtn001 = new ASTSequence ( JJTSEQUENCE ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { assignmentExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } } }


Input: assignment expression ( level 13 ) [CODESPLIT] final public void assignmentExpression ( ) throws ParseException { conditionalTestExpression ( ) ; switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 2 : jj_consume_token ( 2 ) ; ASTAssign jjtn001 = new ASTAssign ( JJTASSIGN ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { assignmentExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } break ; default : jj_la1 [ 1 ] = jj_gen ; ; } }


Input: logical or ( || ) ( level 11 ) [CODESPLIT] final public void logicalOrExpression ( ) throws ParseException { logicalAndExpression ( ) ; label_2 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 5 : case 6 : ; break ; default : jj_la1 [ 3 ] = jj_gen ; break label_2 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 5 : jj_consume_token ( 5 ) ; break ; case 6 : jj_consume_token ( 6 ) ; break ; default : jj_la1 [ 4 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTOr jjtn001 = new ASTOr ( JJTOR ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { logicalAndExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } } }


Input: logical and ( && ) ( level 10 ) [CODESPLIT] final public void logicalAndExpression ( ) throws ParseException { inclusiveOrExpression ( ) ; label_3 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 7 : case 8 : ; break ; default : jj_la1 [ 5 ] = jj_gen ; break label_3 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 7 : jj_consume_token ( 7 ) ; break ; case 8 : jj_consume_token ( 8 ) ; break ; default : jj_la1 [ 6 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTAnd jjtn001 = new ASTAnd ( JJTAND ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { inclusiveOrExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } } }


Input: bitwise or non - short - circuiting or ( | ) ( level 9 ) [CODESPLIT] final public void inclusiveOrExpression ( ) throws ParseException { exclusiveOrExpression ( ) ; label_4 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 9 : case 10 : ; break ; default : jj_la1 [ 7 ] = jj_gen ; break label_4 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 9 : jj_consume_token ( 9 ) ; break ; case 10 : jj_consume_token ( 10 ) ; break ; default : jj_la1 [ 8 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTBitOr jjtn001 = new ASTBitOr ( JJTBITOR ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { exclusiveOrExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } } }


Input: exclusive or ( ^ ) ( level 8 ) [CODESPLIT] final public void exclusiveOrExpression ( ) throws ParseException { andExpression ( ) ; label_5 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 11 : case 12 : ; break ; default : jj_la1 [ 9 ] = jj_gen ; break label_5 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 11 : jj_consume_token ( 11 ) ; break ; case 12 : jj_consume_token ( 12 ) ; break ; default : jj_la1 [ 10 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTXor jjtn001 = new ASTXor ( JJTXOR ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { andExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } } }


Input: bitwise or non - short - circuiting and ( & ) ( level 7 ) [CODESPLIT] final public void andExpression ( ) throws ParseException { equalityExpression ( ) ; label_6 : while ( true ) { switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 13 : case 14 : ; break ; default : jj_la1 [ 11 ] = jj_gen ; break label_6 ; } switch ( ( jj_ntk == - 1 ) ? jj_ntk ( ) : jj_ntk ) { case 13 : jj_consume_token ( 13 ) ; break ; case 14 : jj_consume_token ( 14 ) ; break ; default : jj_la1 [ 12 ] = jj_gen ; jj_consume_token ( - 1 ) ; throw new ParseException ( ) ; } ASTBitAnd jjtn001 = new ASTBitAnd ( JJTBITAND ) ; boolean jjtc001 = true ; jjtree . openNodeScope ( jjtn001 ) ; try { equalityExpression ( ) ; } catch ( Throwable jjte001 ) { if ( jjtc001 ) { jjtree . clearNodeScope ( jjtn001 ) ; jjtc001 = false ; } else { jjtree . popNode ( ) ; } if ( jjte001 instanceof RuntimeException ) { { if ( true ) throw ( RuntimeException ) jjte001 ; } } if ( jjte001 instanceof ParseException ) { { if ( true ) throw ( ParseException ) jjte001 ; } } { if ( true ) throw ( Error ) jjte001 ; } } finally { if ( jjtc001 ) { jjtree . closeNodeScope ( jjtn001 , 2 ) ; } } } }