Bug 1172356 - Improvements for CertificateUsage
Summary: Improvements for CertificateUsage
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: jss
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Christina Fu
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-09 21:50 UTC by Endi Sukma Dewata
Modified: 2016-07-19 12:29 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-19 12:29:57 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Endi Sukma Dewata 2014-12-09 21:50:27 UTC
Currently the CertificateUsage only provides a limited set of functionalities. For example, to translate a usage string into a usage object, one has to write the following code:

  Iterator iterator = CertificateUsage.getCertificateUsages();
  while (iterator.hasNext()) {
      CertificateUsage usage = (CertificateUsage)iterator.next();
      String name = usage.toString();
      if (name.equalsIgnoreCase(usageStr)) return usage;
  }
  return null;

There are some improvements that can be done to make CertificateUsage more usable.

1. The getCertificateUsage() should return a Collection<CertificateUsage> instead of a plain Iterator. Then the above code could be simplified as follows:

  for (CertificateUsage usage : CertificateUsage.getCertificateUsages()) {
      String name = usage.toString();
      if (name.equalsIgnoreCase(usageStr)) return usage;
  }
  return null;

If backward compatibility is important, the CertificateUsage should provide a different method or a static Collection<CertificateUsage> which returns all usage objects:

  for (CertificateUsage usage : CertificateUsage.ALL_USAGES) {
      String name = usage.toString();
      if (name.equalsIgnoreCase(usageStr)) return usage;
  }
  return null;

2. The CertificateUsage should provide proper getter methods for its fields or make them public:

  for (CertificateUsage usage : CertificateUsage.ALL_USAGES) {
      String name = usage.getName();
      if (name.equalsIgnoreCase(usageStr)) return usage;
  }
  return null;

3. The CertificateUsage should provide the above code as a static method, so translating a usage string into a usage object can simply be done as follows:

  CertificateUsage usage = CertificateUsage.valueOf(usageStr);

This method can also be implemented using a HashMap<String, CertificateUsage> instead of Collection<CertificateUsage>.

Comment 1 Jaroslav Reznik 2015-03-03 16:35:11 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 2 Fedora End Of Life 2016-07-19 12:29:57 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.