kaikramer / keystore-explorer

KeyStore Explorer is a free GUI replacement for the Java command-line utilities keytool and jarsigner.
https://keystore-explorer.org/
GNU General Public License v3.0
1.7k stars 275 forks source link

Add serial number formatting #480

Open bennypi opened 9 months ago

bennypi commented 9 months ago

The second attempt to add formatting options for serial numbers, this time based on the current main branch. Again, it's far from finished, but I would like to get some feedback if I'm heading into the right direction.

Some questions which I had during the process:

Feedback is greatly appreciated, don't hold back :)

Fixes #406

kaikramer commented 9 months ago

Thank you very much for this PR! I am very happy that someone is helping out regarding this topic. I'll take a closer look at it tomorrow and also answer your questions.

kaikramer commented 9 months ago
  • Where are the other places where a serial number should be formatted?

What I have done so far is to centralize all the code for generating the hex strings in KSE into one class: org/kse/utilities/io/HexUtil.java

So you can find all places where hex strings are displayed by looking for the usages of the methods in this class.

What causes me most headache is that there are some places where the data is too long to fit into one line, but is also a hex string:

We should probably ignore those for now and only make the format for "one-line" hex strings configurable.

In any case please combine your code with the existing code in Hexutil. You can replace HexUtil, that's fine for me, but in the end there should be only one location in the code where hex strings are formatted.

  • Which variants should be implemented?

The following list seems most reasonable (more exotic variants can be added later if requested):

Not sure if we should also provide an option for hex marker ("0x") on/off. There could be only numbers in the hex string and then it is not distinguishable from decimal without the "0x". But on the other hand the format is either stated in the label (e.g. for serial number) or it is clear that it is hex (e.g. fingerprint)...

  • Is the look&feel tab the right place for this setting?

Yes and I like that you put the example right in the select box.

  • Which rules are used for formatting?

You mean for formatting the Java code? I have just noticed that it is probably a bad idea to have two web pages with contributing guidelines. The one on keystore-explorer.org contains infos on code formatting, but the CONTRIBUTING.md here in the repo does not... If you use IntelliJ, there is a formatter config linked on the website, otherwise just change the setting for indentation from tabs to spaces and you should be fine.

The-Lum commented 9 months ago

Hi @bennypi, and all,

And here are a proposal for the French 'resources.properties':

DPreferences.jcbSerialNumberFormatter.tooltip = S\u00E9lectionner un format pour afficher les num\u00E9ros de s\u00E9rie (S/N)
DPreferences.jlSerialNumberFormatter.text = Format des num\u00E9ros de s\u00E9rie (S/N)\u00A0:

Awaiting your new proposals, Regards, Th.