Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[names] Remove PHP serialization and hashing for Web service cache #18

Open
re1 opened this issue May 27, 2020 · 4 comments
Open

[names] Remove PHP serialization and hashing for Web service cache #18

re1 opened this issue May 27, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@re1
Copy link
Owner

re1 commented May 27, 2020

The Web service cache is as implemented from #15 is currently using PHP string serialization and SHA1 hashing for using hexadecimal strings in order to query cached responses from the currently active OpenUp! project.

This serialization and hashing is to be either removed or improved for language independent use.

@re1 re1 added the enhancement New feature or request label May 27, 2020
@re1
Copy link
Owner Author

re1 commented May 31, 2020

Here is an example of how queries are currently hashed:

id query service_id
32556232 0000043260928acf7cfacb39a6e2c23d88b3280a 2
41756652 0000043260928acf7cfacb39a6e2c23d88b3280a 2
48036015 0000043260928acf7cfacb39a6e2c23d88b3280a 2
59794586 0000043260928acf7cfacb39a6e2c23d88b3280a 2
62229379 0000043260928acf7cfacb39a6e2c23d88b3280a 2
182203 000004611db1b89d7923ca802b6915ef3d563efc 2
3973722 000004611db1b89d7923ca802b6915ef3d563efc 2
6701528 000004611db1b89d7923ca802b6915ef3d563efc 2
11822393 000004611db1b89d7923ca802b6915ef3d563efc 2
41297069 000004611db1b89d7923ca802b6915ef3d563efc 2

@re1
Copy link
Owner Author

re1 commented Jun 2, 2020

In PHP the hashing happens as follows

sha1(serialize("Taraxacum officinale"))

The Java equivalent for this is

String s = Pherialize.serialize("Taraxacum officinale");

try {
    // create MD5 Hash
    MessageDigest digest = MessageDigest.getInstance("SHA-1");
    digest.update(s.getBytes());
    // create Hex String for comparision with existing PHP SHA1 hashes
    StringBuilder hexString = new StringBuilder();
    for (byte b : digest.digest()) hexString.append(String.format("%02X", 0xFF & b));
    // existing query hashes are also in lower case
    s = hexString.toString().toLowerCase();
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
}

where Pherialize is only used to (de-)serialize Strings as in PHP.

@re1
Copy link
Owner Author

re1 commented Jul 22, 2020

Web service responses are also currently serialized as in PHP and not in plain text. In order to fully remove the need for PHP (de-)serialization the existing OpenUp! Web service cache table has to be adjusted.

@re1
Copy link
Owner Author

re1 commented Jul 22, 2020

PHP (de-)serialization for results could temporarily be moved to the TblWebserviceCache class in order to improve readability and avoid unintentional use of (de-)serialized response strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant