commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dapeng Sun (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CRYPTO-74) Full class names make code more difficult to update
Date Tue, 21 Jun 2016 08:53:58 GMT

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

Dapeng Sun edited comment on CRYPTO-74 at 6/21/16 8:53 AM:
-----------------------------------------------------------

Hi Sebb
I created a pr https://github.com/apache/commons-crypto/pull/58 about this.

The alias would be the short names of the classes, it will search them at default package,
if the class is not found, the name would treat as full class name, so that if user have a
custom implement of the interface.

If you think it is okay, I would also refactor the cipher factory.


was (Author: dapengsun):
Hi Sebb, Do you think it is okay to refactor like this https://github.com/apache/commons-crypto/pull/58

> Full class names make code more difficult to update
> ---------------------------------------------------
>
>                 Key: CRYPTO-74
>                 URL: https://issues.apache.org/jira/browse/CRYPTO-74
>             Project: Commons Crypto
>          Issue Type: Improvement
>            Reporter: Sebb
>
> The method CryptoRandomFactory.getCryptoRandom uses the value of a property as the full
name of the CryptoRandom class to be instantiated.
> This is inherently non-portable if the code package names should ever be changed in future.
> One way round this is to add a constant alias for the embedded implementations.
> For example:
> CryptoRandomFactory.java
> public static final String OPENSSL_RANDOM = "OpensslCryptoRandom";
> public static final String JAVA_RANDOM = "JavaCryptoRandom";
> ...
> If the COMMONS_CRYPTO_SECURE_RANDOM_CLASSES_KEY string does not contain a full class
name, then the code would preprend the appropriate package name (or there could be a lookup
table).
> This would also work for the case where the class is provided as a system property value.
> Another advantage of this method is that it simplifies the user code.
> Similar considerations apply to all other factories which use class name strings.
> [Note: the constants must not contain the full package names as that would result in
a binary incompatibility if the names changed.]



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

Mime
View raw message