idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
2,500
private static DSAKeyValidationParameters . Usage getUsage ( int usage ) { if ( usage == DSAParameterGenerationParameters . DIGITAL_SIGNATURE_USAGE ) { return DSAKeyValidationParameters . Usage . DIGITAL_SIGNATURE ; } else if ( usage == DSAParameterGenerationParameters . KEY_ESTABLISHMENT_USAGE ) { return DSAKeyValidationParameters . Usage . KEY_ESTABLISHMENT ; } return DSAKeyValidationParameters . Usage . ANY ; }
Convert usage index to key usage .
2,501
public void addURL ( URL url ) { this . finder . addURI ( URI . create ( url . toExternalForm ( ) ) ) ; }
Add specified URL at the end of the search path .
2,502
public void addURLs ( List < URL > urls ) { for ( URL url : urls ) { addURL ( url ) ; } }
Add specified URLs at the end of the search path .
2,503
protected Class < ? > findClass ( final String name ) throws ClassNotFoundException { try { return AccessController . doPrivileged ( new PrivilegedExceptionAction < Class < ? > > ( ) { public Class < ? > run ( ) throws ClassNotFoundException { String path = name . replace ( '.' , '/' ) . concat ( ".class" ) ; ResourceHandle h = URIClassLoader . this . finder . getResource ( path ) ; if ( h != null ) { try { return defineClass ( name , h ) ; } catch ( IOException e ) { throw new ClassNotFoundException ( name , e ) ; } } else { throw new ClassNotFoundException ( name ) ; } } } , this . acc ) ; } catch ( java . security . PrivilegedActionException pae ) { throw ( ClassNotFoundException ) pae . getException ( ) ; } }
Finds and loads the class with the specified name .
2,504
private boolean isSealed ( String name , Manifest man ) { String path = name . replace ( '.' , '/' ) . concat ( "/" ) ; Attributes attr = man . getAttributes ( path ) ; String sealed = null ; if ( attr != null ) { sealed = attr . getValue ( Name . SEALED ) ; } if ( sealed == null ) { if ( ( attr = man . getMainAttributes ( ) ) != null ) { sealed = attr . getValue ( Name . SEALED ) ; } } return "true" . equalsIgnoreCase ( sealed ) ; }
returns true if the specified package name is sealed according to the given manifest .
2,505
public URL findResource ( final String name ) { return AccessController . doPrivileged ( new PrivilegedAction < URL > ( ) { public URL run ( ) { return URIClassLoader . this . finder . findResource ( name ) ; } } , this . acc ) ; }
Finds the resource with the specified name .
2,506
public Enumeration < URL > findResources ( final String name ) throws IOException { return AccessController . doPrivileged ( new PrivilegedAction < Enumeration < URL > > ( ) { public Enumeration < URL > run ( ) { return URIClassLoader . this . finder . findResources ( name ) ; } } , this . acc ) ; }
Returns an Enumeration of URLs representing all of the resources having the specified name .
2,507
protected ResourceHandle getResourceHandle ( final String name ) { return AccessController . doPrivileged ( new PrivilegedAction < ResourceHandle > ( ) { public ResourceHandle run ( ) { return URIClassLoader . this . finder . getResource ( name ) ; } } , this . acc ) ; }
Finds the ResourceHandle object for the resource with the specified name .
2,508
protected Enumeration < ResourceHandle > getResourceHandles ( final String name ) { return AccessController . doPrivileged ( new PrivilegedAction < Enumeration < ResourceHandle > > ( ) { public Enumeration < ResourceHandle > run ( ) { return URIClassLoader . this . finder . getResources ( name ) ; } } , this . acc ) ; }
Returns an Enumeration of ResourceHandle objects representing all of the resources having the specified name .
2,509
protected void initializePatterns ( ) { this . contentPagePatterns = initializationPagePatterns ( this . contentPages ) ; this . technicalPagePatterns = initializationPagePatterns ( this . technicalPages ) ; Map < Pattern , Pattern > patterns = new HashMap < > ( ) ; for ( String key : this . titles . stringPropertyNames ( ) ) { patterns . put ( Pattern . compile ( key ) , Pattern . compile ( this . titles . getProperty ( key ) ) ) ; } this . titlePatterns = patterns ; }
Initialize regex Patterns for performance reasons .
2,510
protected void executeLicenseGoal ( String goal ) throws MojoExecutionException { Plugin licensePlugin = this . project . getPluginManagement ( ) . getPluginsAsMap ( ) . get ( "com.mycila:license-maven-plugin" ) ; if ( licensePlugin == null ) { throw new MojoExecutionException ( "License plugin could not be found in <pluginManagement>" ) ; } executeMojo ( licensePlugin , goal ( goal ) , configuration ( element ( name ( "header" ) , "license.txt" ) , element ( name ( "strictCheck" ) , "true" ) , element ( name ( "headerDefinitions" ) , element ( name ( "headerDefinition" ) , "license-xml-definition.xml" ) ) , element ( name ( "includes" ) , element ( name ( "include" ) , "src/main/resources/**/*.xml" ) ) ) , executionEnvironment ( this . project , this . mavenSession , this . pluginManager ) ) ; }
Executes a goal of the Maven License plugin ( used for adding or checking for license headers .
2,511
protected Color parseRGB ( String value ) { StringTokenizer items = new StringTokenizer ( value , "," ) ; try { int red = 0 ; if ( items . hasMoreTokens ( ) ) { red = Integer . parseInt ( items . nextToken ( ) . trim ( ) ) ; } int green = 0 ; if ( items . hasMoreTokens ( ) ) { green = Integer . parseInt ( items . nextToken ( ) . trim ( ) ) ; } int blue = 0 ; if ( items . hasMoreTokens ( ) ) { blue = Integer . parseInt ( items . nextToken ( ) . trim ( ) ) ; } return new Color ( red , green , blue ) ; } catch ( NumberFormatException ex ) { throw new ConversionException ( value + "is not a valid RGB colo" , ex ) ; } }
Parsers a String in the form x y z into an SWT RGB class .
2,512
public ResourceHandle getResource ( URL source , String name ) { return getResource ( source , name , new HashSet < > ( ) , null ) ; }
Gets resource with given name at the given source URL . If the URL points to a directory the name is the file path relative to this directory . If the URL points to a JAR file the name identifies an entry in that JAR file . If the URL points to a JAR file the resource is not found in that JAR file and the JAR file has Class - Path attribute the JAR files identified in the Class - Path are also searched for the resource .
2,513
public ResourceHandle getResource ( URL [ ] sources , String name ) { Set < URL > visited = new HashSet < > ( ) ; for ( URL source : sources ) { ResourceHandle h = getResource ( source , name , visited , null ) ; if ( h != null ) { return h ; } } return null ; }
Gets resource with given name at the given search path . The path is searched iteratively one URL at a time . If the URL points to a directory the name is the file path relative to this directory . If the URL points to the JAR file the name identifies an entry in that JAR file . If the URL points to the JAR file the resource is not found in that JAR file and the JAR file has Class - Path attribute the JAR files identified in the Class - Path are also searched for the resource .
2,514
public URL findResource ( URL source , String name ) { return findResource ( source , name , new HashSet < > ( ) , null ) ; }
Fined resource with given name at the given source URL . If the URL points to a directory the name is the file path relative to this directory . If the URL points to a JAR file the name identifies an entry in that JAR file . If the URL points to a JAR file the resource is not found in that JAR file and the JAR file has Class - Path attribute the JAR files identified in the Class - Path are also searched for the resource .
2,515
public URL findResource ( URL [ ] sources , String name ) { Set < URL > visited = new HashSet < > ( ) ; for ( URL source : sources ) { URL url = findResource ( source , name , visited , null ) ; if ( url != null ) { return url ; } } return null ; }
Finds resource with given name at the given search path . The path is searched iteratively one URL at a time . If the URL points to a directory the name is the file path relative to this directory . If the URL points to the JAR file the name identifies an entry in that JAR file . If the URL points to the JAR file the resource is not found in that JAR file and the JAR file has Class - Path attribute the JAR files identified in the Class - Path are also searched for the resource .
2,516
public static String toAlphaNumeric ( String text ) { if ( isEmpty ( text ) ) { return text ; } return stripAccents ( text ) . replaceAll ( "[^a-zA-Z0-9]" , "" ) ; }
Removes all non alpha numerical characters from the passed text . First tries to convert diacritics to their alpha numeric representation .
2,517
public static List < X509GeneralName > getX509GeneralNames ( GeneralNames genNames ) { if ( genNames == null ) { return null ; } GeneralName [ ] names = genNames . getNames ( ) ; List < X509GeneralName > x509names = new ArrayList < X509GeneralName > ( names . length ) ; for ( GeneralName name : names ) { switch ( name . getTagNo ( ) ) { case GeneralName . rfc822Name : x509names . add ( new X509Rfc822Name ( name ) ) ; break ; case GeneralName . dNSName : x509names . add ( new X509DnsName ( name ) ) ; break ; case GeneralName . directoryName : x509names . add ( new X509DirectoryName ( name ) ) ; break ; case GeneralName . uniformResourceIdentifier : x509names . add ( new X509URI ( name ) ) ; break ; case GeneralName . iPAddress : x509names . add ( new X509IpAddress ( name ) ) ; break ; default : x509names . add ( new X509GenericName ( name ) ) ; break ; } } return x509names ; }
Convert general names from Bouncy Castle general names .
2,518
public static EnumSet < KeyUsage > getSetOfKeyUsage ( org . bouncycastle . asn1 . x509 . KeyUsage keyUsage ) { if ( keyUsage == null ) { return null ; } Collection < KeyUsage > usages = new ArrayList < KeyUsage > ( ) ; for ( KeyUsage usage : KeyUsage . values ( ) ) { if ( ( ( ( DERBitString ) keyUsage . toASN1Primitive ( ) ) . intValue ( ) & usage . value ( ) ) > 0 ) { usages . add ( usage ) ; } } return EnumSet . copyOf ( usages ) ; }
Convert usages from Bouncy Castle .
2,519
public static ExtendedKeyUsages getExtendedKeyUsages ( ExtendedKeyUsage usages ) { if ( usages == null ) { return null ; } List < String > usageStr = new ArrayList < String > ( ) ; for ( KeyPurposeId keyPurposeId : usages . getUsages ( ) ) { usageStr . add ( keyPurposeId . getId ( ) ) ; } return new ExtendedKeyUsages ( usageStr ) ; }
Convert extended usages from Bouncy Castle .
2,520
public static GeneralNames getGeneralNames ( X509GeneralName [ ] genNames ) { GeneralName [ ] names = new GeneralName [ genNames . length ] ; int i = 0 ; for ( X509GeneralName name : genNames ) { if ( name instanceof BcGeneralName ) { names [ i ++ ] = ( ( BcGeneralName ) name ) . getGeneralName ( ) ; } else { throw new IllegalArgumentException ( "Unexpected general name: " + name . getClass ( ) . toString ( ) ) ; } } return new GeneralNames ( names ) ; }
Convert a collection of X . 509 general names to Bouncy Castle general names .
2,521
public static org . bouncycastle . asn1 . x509 . KeyUsage getKeyUsage ( EnumSet < KeyUsage > usages ) { int bitmask = 0 ; for ( KeyUsage usage : usages ) { bitmask |= usage . value ( ) ; } return new org . bouncycastle . asn1 . x509 . KeyUsage ( bitmask ) ; }
Convert a set of key usages to Bouncy Castle key usage .
2,522
public static ExtendedKeyUsage getExtendedKeyUsage ( Set < String > usages ) { KeyPurposeId [ ] keyUsages = new KeyPurposeId [ usages . size ( ) ] ; int i = 0 ; for ( String usage : usages ) { keyUsages [ i ++ ] = KeyPurposeId . getInstance ( new ASN1ObjectIdentifier ( usage ) ) ; } return new ExtendedKeyUsage ( keyUsages ) ; }
Convert a set of extended key usages to Bouncy Castle extended key usage .
2,523
public void initialize ( ClassLoader classLoader ) { ComponentAnnotationLoader loader = new ComponentAnnotationLoader ( ) ; loader . initialize ( this , classLoader ) ; try { List < ComponentManagerInitializer > initializers = this . getInstanceList ( ComponentManagerInitializer . class ) ; for ( ComponentManagerInitializer initializer : initializers ) { initializer . initialize ( this ) ; } } catch ( ComponentLookupException e ) { this . logger . error ( "Failed to lookup ComponentManagerInitializer components" , e ) ; } }
Load all component annotations and register them as components .
2,524
private Attributes getAttributes ( StartElement event ) { AttributesImpl attrs = new AttributesImpl ( ) ; if ( ! event . isStartElement ( ) ) { throw new InternalError ( "getAttributes() attempting to process: " + event ) ; } if ( this . filter . getNamespacePrefixes ( ) ) { for ( @ SuppressWarnings ( "unchecked" ) Iterator < Namespace > i = event . getNamespaces ( ) ; i . hasNext ( ) ; ) { Namespace staxNamespace = i . next ( ) ; String uri = staxNamespace . getNamespaceURI ( ) ; if ( uri == null ) { uri = "" ; } String prefix = staxNamespace . getPrefix ( ) ; if ( prefix == null ) { prefix = "" ; } String qName = "xmlns" ; if ( prefix . length ( ) == 0 ) { prefix = qName ; } else { qName = qName + ':' + prefix ; } attrs . addAttribute ( "http://www.w3.org/2000/xmlns/" , prefix , qName , "CDATA" , uri ) ; } } for ( @ SuppressWarnings ( "unchecked" ) Iterator < Attribute > i = event . getAttributes ( ) ; i . hasNext ( ) ; ) { Attribute staxAttr = i . next ( ) ; String uri = staxAttr . getName ( ) . getNamespaceURI ( ) ; if ( uri == null ) { uri = "" ; } String localName = staxAttr . getName ( ) . getLocalPart ( ) ; String prefix = staxAttr . getName ( ) . getPrefix ( ) ; String qName ; if ( prefix == null || prefix . length ( ) == 0 ) { qName = localName ; } else { qName = prefix + ':' + localName ; } String type = staxAttr . getDTDType ( ) ; String value = staxAttr . getValue ( ) ; attrs . addAttribute ( uri , localName , qName , type , value ) ; } return attrs ; }
Get the attributes associated with the given START_ELEMENT StAXevent .
2,525
protected TreeMarshaller createMarshallingContext ( HierarchicalStreamWriter writer , ConverterLookup converterLookup , Mapper mapper ) { return new SafeTreeMarshaller ( writer , converterLookup , mapper , RELATIVE ) ; }
If anything goes wrong with an element don t serialize it
2,526
public Map < String , List < String > > parseQuery ( String query ) { Map < String , List < String > > queryParams = new LinkedHashMap < > ( ) ; if ( query != null ) { for ( NameValuePair params : URLEncodedUtils . parse ( query , StandardCharsets . UTF_8 ) ) { String name = params . getName ( ) ; List < String > values = queryParams . get ( name ) ; if ( values == null ) { values = new ArrayList < > ( ) ; queryParams . put ( name , values ) ; } values . add ( params . getValue ( ) ) ; } } return queryParams ; }
Parse a query string into a map of key - value pairs .
2,527
public static boolean sendEndEvent ( Object filter , FilterDescriptor descriptor , String id , FilterEventParameters parameters ) throws FilterException { FilterElementDescriptor elementDescriptor = descriptor . getElement ( id ) ; if ( elementDescriptor != null && elementDescriptor . getEndMethod ( ) != null ) { sendEvent ( elementDescriptor . getEndMethod ( ) , elementDescriptor , filter , parameters ) ; } else if ( filter instanceof UnknownFilter ) { ( ( UnknownFilter ) filter ) . endUnknwon ( id , parameters ) ; } else { return false ; } return true ; }
Call passed end event if possible .
2,528
public static boolean sendOnEvent ( Object filter , FilterDescriptor descriptor , String id , FilterEventParameters parameters ) throws FilterException { FilterElementDescriptor elementDescriptor = descriptor . getElement ( id ) ; if ( elementDescriptor != null && elementDescriptor . getOnMethod ( ) != null ) { sendEvent ( elementDescriptor . getOnMethod ( ) , elementDescriptor , filter , parameters ) ; } else if ( filter instanceof UnknownFilter ) { ( ( UnknownFilter ) filter ) . onUnknwon ( id , parameters ) ; } else { return false ; } return true ; }
Call passed on event if possible .
2,529
private void onEventListenerComponentAdded ( ComponentDescriptorAddedEvent event , ComponentManager componentManager , ComponentDescriptor < EventListener > descriptor ) { try { EventListener eventListener = componentManager . getInstance ( EventListener . class , event . getRoleHint ( ) ) ; if ( getListener ( eventListener . getName ( ) ) != eventListener ) { addListener ( eventListener ) ; } else { this . logger . warn ( "An Event Listener named [{}] already exists, ignoring the [{}] component" , eventListener . getName ( ) , descriptor . getImplementation ( ) . getName ( ) ) ; } } catch ( ComponentLookupException e ) { this . logger . error ( "Failed to lookup the Event Listener [{}] corresponding to the Component registration " + "event for [{}]. Ignoring the event" , new Object [ ] { event . getRoleHint ( ) , descriptor . getImplementation ( ) . getName ( ) , e } ) ; } }
An Event Listener Component has been dynamically registered in the system add it to our cache .
2,530
private void onEventListenerComponentRemoved ( ComponentDescriptorRemovedEvent event , ComponentManager componentManager , ComponentDescriptor < ? > descriptor ) { EventListener removedEventListener = null ; for ( EventListener eventListener : getListenersByName ( ) . values ( ) ) { if ( eventListener . getClass ( ) == descriptor . getImplementation ( ) ) { removedEventListener = eventListener ; } } if ( removedEventListener != null ) { removeListener ( removedEventListener . getName ( ) ) ; } }
An Event Listener Component has been dynamically unregistered in the system remove it from our cache .
2,531
protected org . bouncycastle . crypto . CipherParameters getBcCipherParameter ( AsymmetricCipherParameters parameters ) { if ( parameters instanceof BcAsymmetricKeyParameters ) { return ( ( BcAsymmetricKeyParameters ) parameters ) . getParameters ( ) ; } throw new UnsupportedOperationException ( "Cipher parameters are incompatible with this signer: " + parameters . getClass ( ) . getName ( ) ) ; }
Convert cipher parameters to Bouncy Castle equivalent .
2,532
public int getDirective ( char [ ] array , int currentIndex , StringBuffer velocityBlock , VelocityParserContext context ) throws InvalidVelocityException { int i = currentIndex + 1 ; StringBuffer directiveNameBuffer = new StringBuffer ( ) ; i = getDirectiveName ( array , i , directiveNameBuffer , null , context ) ; String directiveName = directiveNameBuffer . toString ( ) ; if ( ! VELOCITYDIRECTIVE_NOPARAM . contains ( directiveName ) ) { while ( i < array . length && array [ i ] == ' ' ) { ++ i ; } if ( i < array . length && array [ i ] == '(' ) { i = getMethodParameters ( array , i , null , context ) ; } else { throw new InvalidVelocityException ( ) ; } } if ( VELOCITYDIRECTIVE_ALL . contains ( directiveName ) ) { if ( VELOCITYDIRECTIVE_BEGIN . contains ( directiveName ) ) { context . pushVelocityElement ( new VelocityBlock ( directiveName , VelocityBlock . VelocityType . DIRECTIVE ) ) ; } else if ( VELOCITYDIRECTIVE_END . contains ( directiveName ) ) { context . popVelocityElement ( ) ; } i = getDirectiveEndOfLine ( array , i , null , context ) ; context . setType ( VelocityBlock . VelocityType . DIRECTIVE ) ; } else { context . setType ( VelocityBlock . VelocityType . MACRO ) ; } if ( velocityBlock != null ) { velocityBlock . append ( array , currentIndex , i - currentIndex ) ; } return i ; }
Get any valid Velocity block starting with a sharp character except comments .
2,533
public int getVelocityIdentifier ( char [ ] array , int currentIndex , StringBuffer velocityBlock , VelocityParserContext context ) throws InvalidVelocityException { if ( ! Character . isLetter ( array [ currentIndex ] ) ) { throw new InvalidVelocityException ( ) ; } int i = currentIndex + 1 ; while ( i < array . length && array [ i ] != '}' && isValidVelocityIdentifierChar ( array [ i ] ) ) { ++ i ; } if ( velocityBlock != null ) { velocityBlock . append ( array , currentIndex , i - currentIndex ) ; } return i ; }
Get a valid Velocity identifier used for variable of macro .
2,534
public int getTableElement ( char [ ] array , int currentIndex , StringBuffer velocityBlock , VelocityParserContext context ) { return getParameters ( array , currentIndex , velocityBlock , ']' , context ) ; }
Get a Velocity table .
2,535
protected boolean tryInstallExtension ( ExtensionId extensionId , String namespace ) { DefaultExtensionPlanTree currentTree = this . extensionTree . clone ( ) ; try { installExtension ( extensionId , namespace , currentTree ) ; setExtensionTree ( currentTree ) ; return true ; } catch ( InstallException e ) { if ( getRequest ( ) . isVerbose ( ) ) { this . logger . info ( FAILED_INSTALL_MESSAGE , extensionId , namespace , e ) ; } else { this . logger . debug ( FAILED_INSTALL_MESSAGE , extensionId , namespace , e ) ; } } return false ; }
Try to install the provided extension and update the plan if it s working .
2,536
public static String encode ( String str ) { String encoded ; try { encoded = URLEncoder . encode ( str , "UTF-8" ) . replace ( "." , "%2E" ) . replace ( "*" , "%2A" ) ; } catch ( UnsupportedEncodingException e ) { encoded = str ; } return encoded ; }
Protect passed String to work with as much filesystems as possible .
2,537
public static boolean isWebjar ( Extension extension ) { if ( extension . getType ( ) . equals ( WEBJAR ) ) { return true ; } if ( StringUtils . startsWithAny ( extension . getId ( ) . getId ( ) , "org.webjars:" , "org.webjars." ) ) { return true ; } if ( JarExtensionHandler . WEBJAR . equals ( extension . getProperty ( JarExtensionHandler . PROPERTY_TYPE ) ) ) { return true ; } return false ; }
Find of the passes extension if a webjar .
2,538
private ExtensionHandler getExtensionHandler ( LocalExtension localExtension ) throws ComponentLookupException { return this . componentManager . getInstance ( ExtensionHandler . class , localExtension . getType ( ) . toLowerCase ( ) ) ; }
Get the handler corresponding to the provided extension .
2,539
public static boolean matches ( Pattern patternMatcher , Collection < Filter > filters , Extension extension ) { if ( matches ( patternMatcher , extension . getId ( ) . getId ( ) , extension . getDescription ( ) , extension . getSummary ( ) , extension . getName ( ) , ExtensionIdConverter . toStringList ( extension . getExtensionFeatures ( ) ) ) ) { for ( Filter filter : filters ) { if ( ! matches ( filter , extension ) ) { return false ; } } return true ; } return false ; }
Matches an extension in a case insensitive way .
2,540
public static boolean matches ( Collection < Filter > filters , Extension extension ) { if ( filters != null ) { for ( Filter filter : filters ) { if ( ! matches ( filter , extension ) ) { return false ; } } } return true ; }
Make sure the passed extension matches all filters .
2,541
public static boolean matches ( Pattern patternMatcher , Object ... elements ) { if ( patternMatcher == null ) { return true ; } for ( Object element : elements ) { if ( matches ( patternMatcher , element ) ) { return true ; } } return false ; }
Matches a set of elements in a case insensitive way .
2,542
public static void sort ( List < ? extends Extension > extensions , Collection < SortClause > sortClauses ) { Collections . sort ( extensions , new SortClauseComparator ( sortClauses ) ) ; }
Sort the passed extensions list based on the passed sort clauses .
2,543
public static < E extends Extension > IterableResult < E > appendSearchResults ( IterableResult < E > previousSearchResult , IterableResult < E > result ) { AggregatedIterableResult < E > newResult ; if ( previousSearchResult instanceof AggregatedIterableResult ) { newResult = ( ( AggregatedIterableResult < E > ) previousSearchResult ) ; } else if ( previousSearchResult != null ) { newResult = new AggregatedIterableResult < > ( previousSearchResult . getOffset ( ) ) ; newResult . addSearchResult ( previousSearchResult ) ; } else { return result ; } newResult . addSearchResult ( result ) ; return newResult ; }
Merge provided search results .
2,544
public static IterableResult < Extension > search ( ExtensionQuery query , Iterable < ExtensionRepository > repositories ) throws SearchException { IterableResult < Extension > searchResult = null ; int currentOffset = query . getOffset ( ) > 0 ? query . getOffset ( ) : 0 ; int currentNb = query . getLimit ( ) ; for ( ExtensionRepository repository : repositories ) { try { searchResult = search ( repository , query , currentOffset , currentNb , searchResult ) ; if ( searchResult != null ) { if ( currentOffset > 0 ) { currentOffset = query . getOffset ( ) - searchResult . getTotalHits ( ) ; if ( currentOffset < 0 ) { currentOffset = 0 ; } } if ( currentNb > 0 ) { currentNb = query . getLimit ( ) - searchResult . getSize ( ) ; if ( currentNb < 0 ) { currentNb = 0 ; } } } } catch ( SearchException e ) { LOGGER . error ( "Failed to search on repository [{}] with query [{}]. " + "Ignore and go to next repository." , repository . getDescriptor ( ) . toString ( ) , query , e ) ; } } return searchResult != null ? searchResult : new CollectionIterableResult < > ( 0 , query . getOffset ( ) , Collections . < Extension > emptyList ( ) ) ; }
Search passed repositories based of the provided query .
2,545
public static IterableResult < Extension > search ( ExtensionRepository repository , ExtensionQuery query , IterableResult < Extension > previousSearchResult ) throws SearchException { IterableResult < Extension > result ; if ( repository instanceof Searchable ) { if ( repository instanceof AdvancedSearchable ) { AdvancedSearchable searchableRepository = ( AdvancedSearchable ) repository ; result = searchableRepository . search ( query ) ; } else { Searchable searchableRepository = ( Searchable ) repository ; result = searchableRepository . search ( query . getQuery ( ) , query . getOffset ( ) , query . getLimit ( ) ) ; } if ( previousSearchResult != null ) { result = RepositoryUtils . appendSearchResults ( previousSearchResult , result ) ; } } else { result = previousSearchResult ; } return result ; }
Search one repository .
2,546
private < E , F > void displayInlineDiff ( UnifiedDiffElement < E , F > previous , UnifiedDiffElement < E , F > next , UnifiedDiffConfiguration < E , F > config ) { try { List < F > previousSubElements = config . getSplitter ( ) . split ( previous . getValue ( ) ) ; List < F > nextSubElements = config . getSplitter ( ) . split ( next . getValue ( ) ) ; DiffResult < F > diffResult = this . diffManager . diff ( previousSubElements , nextSubElements , config ) ; List < InlineDiffChunk < F > > chunks = this . inlineDisplayer . display ( diffResult ) ; previous . setChunks ( new ArrayList < InlineDiffChunk < F > > ( ) ) ; next . setChunks ( new ArrayList < InlineDiffChunk < F > > ( ) ) ; for ( InlineDiffChunk < F > chunk : chunks ) { if ( ! chunk . isAdded ( ) ) { previous . getChunks ( ) . add ( chunk ) ; } if ( ! chunk . isDeleted ( ) ) { next . getChunks ( ) . add ( chunk ) ; } } } catch ( DiffException e ) { } }
Computes the changes between two versions of an element by splitting the element into sub - elements and displays the result using the in - line format .
2,547
protected List < Element > filterChildren ( Element parent , String tagName ) { List < Element > result = new ArrayList < Element > ( ) ; Node current = parent . getFirstChild ( ) ; while ( current != null ) { if ( current . getNodeName ( ) . equals ( tagName ) ) { result . add ( ( Element ) current ) ; } current = current . getNextSibling ( ) ; } return result ; }
Utility method for filtering an element s children with a tagName .
2,548
protected List < Element > filterDescendants ( Element parent , String [ ] tagNames ) { List < Element > result = new ArrayList < Element > ( ) ; for ( String tagName : tagNames ) { NodeList nodes = parent . getElementsByTagName ( tagName ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { Element element = ( Element ) nodes . item ( i ) ; result . add ( element ) ; } } return result ; }
Utility method for filtering an element s descendants by their tag names .
2,549
protected boolean hasAttribute ( List < Element > elements , String attributeName , boolean checkValue ) { boolean hasAttribute = true ; if ( ! checkValue ) { for ( Element e : elements ) { hasAttribute = e . hasAttribute ( attributeName ) ? hasAttribute : false ; } } else { String attributeValue = null ; for ( Element e : elements ) { attributeValue = attributeValue == null ? e . getAttribute ( attributeName ) : attributeValue ; hasAttribute = e . getAttribute ( attributeName ) . equals ( attributeValue ) ? hasAttribute : false ; } } return hasAttribute ; }
Utility method for checking if a list of elements have the same attribute set . If the checkValue is true the values of the given attribute will be checked for equivalency .
2,550
protected void moveChildren ( Element parent , Element destination ) { NodeList children = parent . getChildNodes ( ) ; while ( children . getLength ( ) > 0 ) { destination . appendChild ( parent . removeChild ( parent . getFirstChild ( ) ) ) ; } }
Moves all child elements of the parent into destination element .
2,551
static org . bouncycastle . crypto . params . DHParameters getDhParameters ( SecureRandom random , DHKeyParametersGenerationParameters params ) { DHParametersGenerator paramGen = new DHParametersGenerator ( ) ; paramGen . init ( params . getStrength ( ) * 8 , params . getCertainty ( ) , random ) ; return paramGen . generateParameters ( ) ; }
Generate DH parameters .
2,552
private DefaultLocalExtension loadDescriptor ( File descriptor ) throws InvalidExtensionException { FileInputStream fis ; try { fis = new FileInputStream ( descriptor ) ; } catch ( FileNotFoundException e ) { throw new InvalidExtensionException ( "Failed to open descriptor for reading" , e ) ; } try { DefaultLocalExtension localExtension = this . extensionSerializer . loadLocalExtensionDescriptor ( this . repository , fis ) ; localExtension . setDescriptorFile ( descriptor ) ; localExtension . setFile ( getFile ( descriptor , DESCRIPTOR_EXT , localExtension . getType ( ) ) ) ; if ( ! localExtension . getFile ( ) . getFile ( ) . exists ( ) ) { throw new InvalidExtensionException ( "Failed to load local extension [" + descriptor + "]: [" + localExtension . getFile ( ) + "] file does not exists" ) ; } return localExtension ; } finally { try { fis . close ( ) ; } catch ( IOException e ) { LOGGER . error ( "Failed to close stream for file [" + descriptor + "]" , e ) ; } } }
Local extension descriptor from a file .
2,553
private String getFilePath ( ExtensionId id , String fileExtension ) { String encodedId = PathUtils . encode ( id . getId ( ) ) ; String encodedVersion = PathUtils . encode ( id . getVersion ( ) . toString ( ) ) ; String encodedType = PathUtils . encode ( fileExtension ) ; return encodedId + File . separator + encodedVersion + File . separator + encodedId + '-' + encodedVersion + '.' + encodedType ; }
Get file path in the local extension repository .
2,554
public void removeExtension ( DefaultLocalExtension extension ) throws IOException { File descriptorFile = extension . getDescriptorFile ( ) ; if ( descriptorFile == null ) { throw new IOException ( "Exception does not exists" ) ; } descriptorFile . delete ( ) ; DefaultLocalExtensionFile extensionFile = extension . getFile ( ) ; extensionFile . getFile ( ) . delete ( ) ; }
Remove extension from storage .
2,555
private void parse ( ) { this . elements = new ArrayList < > ( ) ; try { for ( Tokenizer tokenizer = new Tokenizer ( this . rawVersion ) ; tokenizer . next ( ) ; ) { Element element = new Element ( tokenizer ) ; this . elements . add ( element ) ; if ( element . getVersionType ( ) != Type . STABLE ) { this . type = element . getVersionType ( ) ; } } trimPadding ( this . elements ) ; } catch ( Exception e ) { LOGGER . error ( "Failed to parse version [" + this . rawVersion + "]" , e ) ; this . elements . add ( new Element ( this . rawVersion ) ) ; } }
Parse the string representation of the version into separated elements .
2,556
private static void trimPadding ( List < Element > elements ) { for ( ListIterator < Element > it = elements . listIterator ( elements . size ( ) ) ; it . hasPrevious ( ) ; ) { Element element = it . previous ( ) ; if ( element . compareTo ( null ) == 0 ) { it . remove ( ) ; } else { break ; } } }
Remove empty elements .
2,557
private static int comparePadding ( List < Element > elements , int index , Boolean number ) { int rel = 0 ; for ( Iterator < Element > it = elements . listIterator ( index ) ; it . hasNext ( ) ; ) { Element element = it . next ( ) ; if ( number != null && number . booleanValue ( ) != element . isNumber ( ) ) { break ; } rel = element . compareTo ( null ) ; if ( rel != 0 ) { break ; } } return rel ; }
Compare the end of the version with 0 .
2,558
public static Collection < String > importProperty ( MutableExtension extension , String propertySuffix , Collection < String > def ) { Object obj = importProperty ( extension , propertySuffix ) ; if ( obj == null ) { return def ; } else if ( obj instanceof Collection ) { return ( Collection ) obj ; } else if ( obj instanceof String [ ] ) { return Arrays . asList ( ( String [ ] ) obj ) ; } else { return importPropertyStringList ( obj . toString ( ) , true ) ; } }
Delete and return the value of the passed special property as a Collection of Strings .
2,559
protected void sendEntryAddedEvent ( CacheEntryEvent < T > event ) { for ( org . xwiki . cache . event . CacheEntryListener < T > listener : this . cacheEntryListeners . getListeners ( org . xwiki . cache . event . CacheEntryListener . class ) ) { listener . cacheEntryAdded ( event ) ; } }
Helper method to send event when a new cache entry is inserted .
2,560
protected void sendEntryRemovedEvent ( CacheEntryEvent < T > event ) { for ( org . xwiki . cache . event . CacheEntryListener < T > listener : this . cacheEntryListeners . getListeners ( org . xwiki . cache . event . CacheEntryListener . class ) ) { listener . cacheEntryRemoved ( event ) ; } disposeCacheValue ( event . getEntry ( ) . getValue ( ) ) ; }
Helper method to send event when an existing cache entry is removed .
2,561
protected void sendEntryModifiedEvent ( CacheEntryEvent < T > event ) { for ( org . xwiki . cache . event . CacheEntryListener < T > listener : this . cacheEntryListeners . getListeners ( org . xwiki . cache . event . CacheEntryListener . class ) ) { listener . cacheEntryModified ( event ) ; } }
Helper method to send event when a cache entry is modified .
2,562
protected void disposeCacheValue ( T value ) { if ( value instanceof DisposableCacheValue ) { try { ( ( DisposableCacheValue ) value ) . dispose ( ) ; } catch ( Throwable e ) { LOGGER . warn ( "Error when trying to dispose a cache object of cache [{}]" , this . configuration != null ? this . configuration . getConfigurationId ( ) : null , e ) ; } } }
Dispose the value being removed from the cache .
2,563
public X509ExtensionBuilder addExtension ( ASN1ObjectIdentifier oid , boolean critical , ASN1Encodable value ) { try { this . extensions . addExtension ( oid , critical , value . toASN1Primitive ( ) . getEncoded ( ASN1Encoding . DER ) ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Invalid extension value, it could not be properly DER encoded." ) ; } return this ; }
Add an extension .
2,564
public Version getVersion ( String rawVersion ) { Version version = this . versions . get ( rawVersion ) ; if ( version == null ) { version = new DefaultVersion ( rawVersion ) ; this . versions . put ( rawVersion , version ) ; } return version ; }
Store and return a weak reference equals to the passed version .
2,565
public VersionConstraint getVersionConstraint ( String rawConstraint ) { VersionConstraint constraint = this . versionConstrains . get ( rawConstraint ) ; if ( constraint == null ) { constraint = new DefaultVersionConstraint ( rawConstraint ) ; this . versionConstrains . put ( rawConstraint , constraint ) ; } return constraint ; }
Store and return a weak reference equals to the passed version constraint .
2,566
protected void extendsTBSCertificate ( BcX509TBSCertificateBuilder builder , CertifiedPublicKey issuer , PrincipalIndentifier subjectName , PublicKeyParameters subject , X509CertificateParameters parameters ) throws IOException { }
Extend TBS certificate depending of certificate version .
2,567
public TBSCertificate buildTBSCertificate ( PrincipalIndentifier subjectName , PublicKeyParameters subject , X509CertificateParameters parameters ) throws IOException { PrincipalIndentifier issuerName ; CertifiedPublicKey issuer = null ; if ( this . signer instanceof CertifyingSigner ) { issuer = ( ( CertifyingSigner ) this . signer ) . getCertifier ( ) ; issuerName = issuer . getSubject ( ) ; } else { issuerName = subjectName ; } BcX509TBSCertificateBuilder builder = getTBSCertificateBuilder ( ) ; builder . setSerialNumber ( new BigInteger ( 128 , this . random ) ) . setIssuer ( issuerName ) ; addValidityDates ( builder ) ; extendsTBSCertificate ( builder , issuer , subjectName , subject , parameters ) ; return builder . setSubject ( subjectName ) . setSubjectPublicKeyInfo ( subject ) . setSignature ( this . signer ) . build ( ) ; }
Build the TBS Certificate .
2,568
private void runInitializers ( ExecutionContext context ) throws ExecutionContextException { for ( ExecutionContextInitializer initializer : this . initializerProvider . get ( ) ) { initializer . initialize ( context ) ; } }
Run the initializers .
2,569
private Class < ? > getFieldRole ( Field field , Requirement requirement ) { Class < ? > role ; if ( isDependencyOfListType ( field . getType ( ) ) ) { role = getGenericRole ( field ) ; } else { role = field . getType ( ) ; } return role ; }
Extract component role from the field to inject .
2,570
private void openTag ( String qName , Attributes atts ) { this . result . append ( '<' ) . append ( qName ) ; for ( int i = 0 ; i < atts . getLength ( ) ; i ++ ) { this . result . append ( ' ' ) . append ( atts . getQName ( i ) ) . append ( "=\"" ) . append ( atts . getValue ( i ) ) . append ( '\"' ) ; } this . result . append ( '>' ) ; }
Append an open tag with the given specification to the result buffer .
2,571
private void checkValue ( Object value ) { if ( this . nonNull && value == null ) { throw new IllegalArgumentException ( String . format ( "The property [%s] may not be null!" , getKey ( ) ) ) ; } if ( getType ( ) != null && value != null && ! getType ( ) . isAssignableFrom ( value . getClass ( ) ) ) { throw new IllegalArgumentException ( String . format ( "The value of property [%s] must be of type [%s], but was [%s]" , getKey ( ) , getType ( ) , value . getClass ( ) ) ) ; } }
Check that the value is compatible with the configure constraints .
2,572
protected static int [ ] newKeySizeArray ( int minSize , int maxSize , int step ) { int [ ] result = new int [ ( ( maxSize - minSize ) / step ) + 1 ] ; for ( int i = minSize , j = 0 ; i <= maxSize ; i += step , j ++ ) { result [ j ] = i ; } return result ; }
Helper function to create supported key size arrays .
2,573
public BcX509v3TBSCertificateBuilder setExtensions ( CertifiedPublicKey issuer , PublicKeyParameters subject , X509Extensions extensions1 , X509Extensions extensions2 ) throws IOException { DefaultX509ExtensionBuilder extBuilder = new DefaultX509ExtensionBuilder ( ) ; extBuilder . addAuthorityKeyIdentifier ( issuer ) . addSubjectKeyIdentifier ( subject ) . addExtensions ( extensions1 ) . addExtensions ( extensions2 ) ; if ( ! extBuilder . isEmpty ( ) ) { this . tbsGen . setExtensions ( ( ( BcX509Extensions ) extBuilder . build ( ) ) . getExtensions ( ) ) ; } return this ; }
Set the extensions of a v3 certificate .
2,574
public < E > List < E > unmodifiable ( List < E > input ) { if ( input == null ) { return null ; } return Collections . unmodifiableList ( input ) ; }
Returns an unmodifiable view of the specified list .
2,575
public < K , V > Map < K , V > unmodifiable ( Map < K , V > input ) { if ( input == null ) { return null ; } return Collections . unmodifiableMap ( input ) ; }
Returns an unmodifiable view of the specified map .
2,576
public < E > Set < E > unmodifiable ( Set < E > input ) { if ( input == null ) { return null ; } return Collections . unmodifiableSet ( input ) ; }
Returns an unmodifiable view of the specified set .
2,577
public < E > Collection < E > unmodifiable ( Collection < E > input ) { if ( input == null ) { return null ; } return Collections . unmodifiableCollection ( input ) ; }
Returns an unmodifiable view of the specified collection .
2,578
public < E > boolean reverse ( List < E > input ) { if ( input == null ) { return false ; } try { Collections . reverse ( input ) ; return true ; } catch ( UnsupportedOperationException ex ) { return false ; } }
Reverse the order of the elements within a list so that the last element is moved to the beginning of the list the next - to - last element to the second position and so on . The input list is modified in place so this operation will succeed only if the list is modifiable .
2,579
public < E extends Comparable < E > > boolean sort ( List < E > input ) { if ( input == null ) { return false ; } try { Collections . sort ( input ) ; return true ; } catch ( UnsupportedOperationException ex ) { return false ; } }
Sort the elements within a list according to their natural order . The input list is modified in place so this operation will succeed only if the list is modifiable .
2,580
private < E > boolean isFullyModified ( List commonAncestor , Patch < E > patchCurrent ) { return patchCurrent . size ( ) == 1 && commonAncestor . size ( ) == patchCurrent . get ( 0 ) . getPrevious ( ) . size ( ) ; }
Check if the content is completely different between the ancestor and the current version
2,581
public Iterator getIterator ( Object obj , Info i ) throws Exception { if ( obj != null ) { SecureIntrospectorControl sic = ( SecureIntrospectorControl ) this . introspector ; if ( sic . checkObjectExecutePermission ( obj . getClass ( ) , null ) ) { return super . getIterator ( obj , i ) ; } else { this . log . warn ( "Cannot retrieve iterator from " + obj . getClass ( ) + " due to security restrictions." ) ; } } return null ; }
Get an iterator from the given object . Since the superclass method this secure version checks for execute permission .
2,582
protected void unpackXARToOutputDirectory ( Artifact artifact , String [ ] includes , String [ ] excludes ) throws MojoExecutionException { if ( ! this . outputBuildDirectory . exists ( ) ) { this . outputBuildDirectory . mkdirs ( ) ; } File file = artifact . getFile ( ) ; unpack ( file , this . outputBuildDirectory , "XAR Plugin" , false , includes , excludes ) ; }
Unpacks A XAR artifacts into the build output directory along with the project s XAR files .
2,583
protected Set < Artifact > resolveArtifactDependencies ( Artifact artifact ) throws ArtifactResolutionException , ArtifactNotFoundException , ProjectBuildingException { Artifact pomArtifact = this . factory . createArtifact ( artifact . getGroupId ( ) , artifact . getArtifactId ( ) , artifact . getVersion ( ) , "" , "pom" ) ; MavenProject pomProject = this . mavenProjectBuilder . buildFromRepository ( pomArtifact , this . remoteRepos , this . local ) ; return resolveDependencyArtifacts ( pomProject ) ; }
This method resolves all transitive dependencies of an artifact .
2,584
protected XWikiDocument getDocFromXML ( File file ) throws MojoExecutionException { XWikiDocument doc ; try { doc = new XWikiDocument ( ) ; doc . fromXML ( file ) ; } catch ( Exception e ) { throw new MojoExecutionException ( String . format ( "Failed to parse [%s]." , file . getAbsolutePath ( ) ) , e ) ; } return doc ; }
Load a XWiki document from its XML representation .
2,585
private void repair ( ) throws IOException { File folder = this . configuration . getStorage ( ) ; if ( folder . exists ( ) ) { if ( ! folder . isDirectory ( ) ) { throw new IOException ( "Not a directory: " + folder ) ; } repairFolder ( folder ) ; } }
Load jobs from directory .
2,586
public void runJob ( ) { try { this . currentJob = this . jobQueue . take ( ) ; ExecutionContext context = new ExecutionContext ( ) ; try { this . executionContextManager . initialize ( context ) ; } catch ( ExecutionContextException e ) { throw new RuntimeException ( "Failed to initialize Job " + this . currentJob + " execution context" , e ) ; } this . currentJob . run ( ) ; } catch ( InterruptedException e ) { } finally { this . execution . removeContext ( ) ; } }
Execute one job .
2,587
private void initRepositoryFeatures ( ) { if ( this . repositoryVersion == null ) { this . repositoryVersion = new DefaultVersion ( Resources . VERSION10 ) ; this . filterable = false ; this . sortable = false ; CloseableHttpResponse response ; try { response = getRESTResource ( this . rootUriBuider ) ; } catch ( IOException e ) { return ; } try { Repository repository = getRESTObject ( response ) ; this . repositoryVersion = new DefaultVersion ( repository . getVersion ( ) ) ; this . filterable = repository . isFilterable ( ) == Boolean . TRUE ; this . sortable = repository . isSortable ( ) == Boolean . TRUE ; } catch ( Exception e ) { LOGGER . error ( "Failed to get repository features" , e ) ; } } }
Check what is supported by the remote repository .
2,588
public void fromXML ( Document domdoc ) throws DocumentException { this . encoding = domdoc . getXMLEncoding ( ) ; Element rootElement = domdoc . getRootElement ( ) ; this . reference = readDocumentReference ( domdoc ) ; this . locale = rootElement . attributeValue ( "locale" ) ; if ( this . locale == null ) { this . locale = readElement ( rootElement , "language" ) ; } this . defaultLanguage = readElement ( rootElement , "defaultLanguage" ) ; this . creator = readElement ( rootElement , "creator" ) ; this . author = readElement ( rootElement , AUTHOR_TAG ) ; this . contentAuthor = readElement ( rootElement , "contentAuthor" ) ; this . version = readElement ( rootElement , "version" ) ; this . parent = readElement ( rootElement , "parent" ) ; this . comment = readElement ( rootElement , "comment" ) ; this . minorEdit = readElement ( rootElement , "minorEdit" ) ; this . attachmentData = readAttachmentData ( rootElement ) ; this . isHidden = Boolean . parseBoolean ( readElement ( rootElement , "hidden" ) ) ; this . title = readElement ( rootElement , "title" ) ; this . syntaxId = readElement ( rootElement , "syntaxId" ) ; this . content = readElement ( rootElement , "content" ) ; this . datePresent = isElementPresent ( rootElement , "date" ) ; this . contentUpdateDatePresent = isElementPresent ( rootElement , "contentUpdateDate" ) ; this . creationDatePresent = isElementPresent ( rootElement , "creationDate" ) ; this . attachmentDatePresent = rootElement . selectSingleNode ( "//attachment/date" ) != null ; if ( ! rootElement . selectNodes ( "//object/className[text() = 'XWiki.TranslationDocumentClass']" ) . isEmpty ( ) ) { this . containsTranslations = true ; for ( Node node : rootElement . selectNodes ( "//object/className[text() = 'XWiki.TranslationDocumentClass']/../property/scope" ) ) { this . translationVisibilities . add ( node . getStringValue ( ) ) ; } } }
Parse XML document to extract document information .
2,589
public static String readElement ( Element rootElement , String elementName ) throws DocumentException { String result = null ; Element element = rootElement . element ( elementName ) ; if ( element != null ) { if ( ! element . isTextOnly ( ) ) { throw new DocumentException ( "Unexpected non-text content found in element [" + elementName + "]" ) ; } result = element . getText ( ) ; } return result ; }
Read an element from the XML .
2,590
public static X509CertificateHolder getX509CertificateHolder ( CertifiedPublicKey cert ) { if ( cert instanceof BcX509CertifiedPublicKey ) { return ( ( BcX509CertifiedPublicKey ) cert ) . getX509CertificateHolder ( ) ; } else { try { return new X509CertificateHolder ( cert . getEncoded ( ) ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Invalid certified public key, unable to encode." ) ; } } }
Convert certified public key to certificate holder .
2,591
public static AsymmetricKeyParameter getAsymmetricKeyParameter ( PublicKeyParameters publicKey ) { if ( publicKey instanceof BcAsymmetricKeyParameters ) { return ( ( BcAsymmetricKeyParameters ) publicKey ) . getParameters ( ) ; } else { try { return PublicKeyFactory . createKey ( publicKey . getEncoded ( ) ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Invalid public key, unable to encode." ) ; } } }
Convert public key parameters to asymmetric key parameter .
2,592
public static SubjectPublicKeyInfo getSubjectPublicKeyInfo ( PublicKeyParameters publicKey ) { try { if ( publicKey instanceof BcPublicKeyParameters ) { return ( ( BcPublicKeyParameters ) publicKey ) . getSubjectPublicKeyInfo ( ) ; } else { return SubjectPublicKeyInfoFactory . createSubjectPublicKeyInfo ( getAsymmetricKeyParameter ( publicKey ) ) ; } } catch ( IOException e ) { throw new IllegalArgumentException ( "Invalid public key, unable to get subject info." ) ; } }
Convert public key parameter to subject public key info .
2,593
public static X509CertificateHolder getX509CertificateHolder ( TBSCertificate tbsCert , byte [ ] signature ) { ASN1EncodableVector v = new ASN1EncodableVector ( ) ; v . add ( tbsCert ) ; v . add ( tbsCert . getSignature ( ) ) ; v . add ( new DERBitString ( signature ) ) ; return new X509CertificateHolder ( Certificate . getInstance ( new DERSequence ( v ) ) ) ; }
Build the structure of an X . 509 certificate .
2,594
public static boolean isAlgorithlIdentifierEqual ( AlgorithmIdentifier id1 , AlgorithmIdentifier id2 ) { if ( ! id1 . getAlgorithm ( ) . equals ( id2 . getAlgorithm ( ) ) ) { return false ; } if ( id1 . getParameters ( ) == null ) { return ! ( id2 . getParameters ( ) != null && ! id2 . getParameters ( ) . equals ( DERNull . INSTANCE ) ) ; } if ( id2 . getParameters ( ) == null ) { return ! ( id1 . getParameters ( ) != null && ! id1 . getParameters ( ) . equals ( DERNull . INSTANCE ) ) ; } return id1 . getParameters ( ) . equals ( id2 . getParameters ( ) ) ; }
Compare two algorithm identifier .
2,595
public static Signer updateDEREncodedObject ( Signer signer , ASN1Encodable tbsObj ) throws IOException { OutputStream sOut = signer . getOutputStream ( ) ; DEROutputStream dOut = new DEROutputStream ( sOut ) ; dOut . writeObject ( tbsObj ) ; sOut . close ( ) ; return signer ; }
DER encode an ASN . 1 object into the given signer and return the signer .
2,596
public static X500Name getX500Name ( PrincipalIndentifier principal ) { if ( principal instanceof BcPrincipalIdentifier ) { return ( ( BcPrincipalIdentifier ) principal ) . getX500Name ( ) ; } else { return new X500Name ( principal . getName ( ) ) ; } }
Convert principal identifier to X . 500 name .
2,597
public static AlgorithmIdentifier getSignerAlgoritmIdentifier ( Signer signer ) { if ( signer instanceof ContentSigner ) { return ( ( ContentSigner ) signer ) . getAlgorithmIdentifier ( ) ; } else { return AlgorithmIdentifier . getInstance ( signer . getEncoded ( ) ) ; } }
Get the algorithm identifier of a signer .
2,598
public static CertifiedPublicKey convertCertificate ( CertificateFactory certFactory , X509CertificateHolder cert ) { if ( cert == null ) { return null ; } if ( certFactory instanceof BcX509CertificateFactory ) { return ( ( BcX509CertificateFactory ) certFactory ) . convert ( cert ) ; } else { try { return certFactory . decode ( cert . getEncoded ( ) ) ; } catch ( IOException e ) { throw new IllegalArgumentException ( "Invalid Certificate, unable to encode" , e ) ; } } }
Convert a Bouncy Castle certificate holder into a certified public key .
2,599
protected void addCachedExtension ( E extension ) { if ( ! this . extensions . containsKey ( extension . getId ( ) ) ) { this . extensions . put ( extension . getId ( ) , extension ) ; addCachedExtensionVersion ( extension . getId ( ) . getId ( ) , extension ) ; if ( ! this . strictId ) { for ( String feature : extension . getFeatures ( ) ) { addCachedExtensionVersion ( feature , extension ) ; } } } }
Register a new extension .