[ 
https://issues.apache.org/jira/browse/PDFBOX-2963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14738948#comment-14738948
 ] 

Tilman Hausherr commented on PDFBOX-2963:
-----------------------------------------

Whatever is decided, it should not require any change from people who don't 
care, i.e. who "just want it to work".

How about this?
{code}
        Provider provider = null;
        try
        {
            Class<Provider> providerClass = (Class<Provider>) 
Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
            provider = providerClass.newInstance();
            Security.addProvider(provider);
        }
        catch (InstantiationException ex)
        {
            //...
        }
        catch (IllegalAccessException ex)
        {
            //...
        }
        catch (ClassNotFoundException ex)
        {
            // ... add information text that BC is not installed and that 
security features won't be available unless another provider is registered with 
Security.addProvider()
        }
{code}
Users who'd want another provider could call {{Security.addProvider()}} 
themselves.

However users who work with public key proteced PDFs would always have the 
PublicKeySecurityHandler class which requires BC. These users would have to call
{code}
Security.removeProvider("BC");
Security.addProvider(....);
{code}

> Remove Bouncy Castle Reference
> ------------------------------
>
>                 Key: PDFBOX-2963
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2963
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Crypto, PDModel
>    Affects Versions: 1.8.9, 1.8.10, 2.0.0
>            Reporter: Johnny Minty
>
> PDFBox Versions 1.8.X and 2.0.X add Bouncy Castle as a security provider 
> explicitly (Hard coded)
> Referencing bouncy castle explicitly ties PDF box to a specific provider 
> implementation.
> Instead of referencing BouncyCastleProvider explicitly provide an option to 
> select another provider or alternatively allow a way to override the default. 
> Version 1.8.X:
> https://github.com/apache/pdfbox/blob/1.8.10/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandlersManager.java
> {code}
> public static SecurityHandlersManager getInstance()
>     {
>         if(instance == null)
>         {
>             instance = new SecurityHandlersManager();
>             Security.addProvider(new BouncyCastleProvider());
>         }
>         return instance;
>     }
> {code}
> Version 2.0.0:
> https://github.com/apache/pdfbox/blob/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/encryption/SecurityHandlerFactory.java
> {code}
>    static
>     {
>         Security.addProvider(new BouncyCastleProvider());
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to