Uploaded image for project: 'EJBCA'
  1. EJBCA
  2. ECA-6068

Info message in the Admin GUI is shown with red colour

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Cosmetic
    • Resolution: Fixed
    • Affects Version/s: EJBCA 6.8.0
    • Fix Version/s: None
    • Component/s: CA GUI
    • Labels:
      None

      Description

      Description

      Some info messages generated by EJBCA Admin GUI are shown in bold red and can be confused with an error message.

      Steps to reproduce

      1. Go to /ejbca/adminweb/ and click "Crypto Tokens" on the left
      2. Click "Create new..."
      3. Fill in the required fields and click "Save"

      Result

      EJBCA Admin GUI generates a message in red which reads "CryptoToken created successfully."

      Proposed improvement

      Make this text bold green instead of bold red to signal to the user that the operation completed without errors.

      Proposed fix

      Replace CryptoTokenMBean.saveCurrentCryptoToken with the following code:

      public void saveCurrentCryptoToken() throws AuthorizationDeniedException {
      try {
      final String secret1 = getCurrentCryptoToken().getSecret1();
      final String secret2 = getCurrentCryptoToken().getSecret2();
      if (!secret1.equals(secret2)) { super.addNonTranslatedErrorMessage("Authentication codes do not match!"); return; }
      final Properties properties = new Properties();
      String className = null;
      if (PKCS11CryptoToken.class.getSimpleName().equals(getCurrentCryptoToken().getType())) {
      className = PKCS11CryptoToken.class.getName();
      String library = getCurrentCryptoToken().getP11Library();
      properties.setProperty(PKCS11CryptoToken.SHLIB_LABEL_KEY, library);
      String slotTextValue = getCurrentCryptoToken().getP11Slot().trim();
      String slotLabelType = getCurrentCryptoToken().getP11SlotLabelType();
      //Perform some name validation
      if(slotLabelType.equals(Pkcs11SlotLabelType.SLOT_NUMBER.getKey())) {
      if(!Pkcs11SlotLabelType.SLOT_NUMBER.validate(slotTextValue)) { super.addNonTranslatedErrorMessage("Slot must be an absolute number."); }
      } else if(slotLabelType.equals(Pkcs11SlotLabelType.SLOT_INDEX.getKey())) {
      if(slotTextValue.charAt(0) != 'i') { slotTextValue = "i" + slotTextValue; }
      if(!Pkcs11SlotLabelType.SLOT_INDEX.validate(slotTextValue)) { super.addNonTranslatedErrorMessage("Slot must be an absolute number or use prefix 'i' for indexed slots."); }
      }

      // Verify that it is allowed
      SlotList allowedSlots = getP11SlotList();
      if (allowedSlots != null && !allowedSlots.contains(slotTextValue)) { throw new IllegalArgumentException("Slot number "+slotTextValue+" is not allowed. Allowed slots are: "+allowedSlots); }

      properties.setProperty(PKCS11CryptoToken.SLOT_LABEL_VALUE, slotTextValue);
      properties.setProperty(PKCS11CryptoToken.SLOT_LABEL_TYPE, slotLabelType);
      // The default should be null, but we will get a value "default" from the GUI code in this case..
      final String p11AttributeFile = getCurrentCryptoToken().getP11AttributeFile();
      if (!"default".equals(p11AttributeFile)) { properties.setProperty(PKCS11CryptoToken.ATTRIB_LABEL_KEY, p11AttributeFile); }
      } else if (SoftCryptoToken.class.getSimpleName().equals(getCurrentCryptoToken().getType())) { className = SoftCryptoToken.class.getName(); properties.setProperty(SoftCryptoToken.NODEFAULTPWD, "true"); }

      if (getCurrentCryptoToken().isAllowExportPrivateKey()) { properties.setProperty(CryptoToken.ALLOW_EXTRACTABLE_PRIVATE_KEY, String.valueOf(getCurrentCryptoToken().isAllowExportPrivateKey())); }
      if (getCurrentCryptoToken().getKeyPlaceholders() != null) { properties.setProperty(CryptoToken.KEYPLACEHOLDERS_PROPERTY, getCurrentCryptoToken().getKeyPlaceholders()); }

      final char[] secret = getCurrentCryptoToken().getSecret1().toCharArray();
      final String name = getCurrentCryptoToken().getName();
      if (getCurrentCryptoTokenId() == 0) {
      if (secret.length>0) {
      if (getCurrentCryptoToken().isAutoActivate()) { BaseCryptoToken.setAutoActivatePin(properties, new String(secret), true); }
      currentCryptoTokenId = cryptoTokenManagementSession.createCryptoToken(authenticationToken, name, className,
      properties, null, secret);
      super.addNonTranslatedInfoMessage("CryptoToken created successfully.");
      } else { super.addNonTranslatedErrorMessage("You must provide an authentication code to create a CryptoToken."); }
      } else {
      if (getCurrentCryptoToken().isAutoActivate()) {
      if (secret.length>0) { BaseCryptoToken.setAutoActivatePin(properties, new String(secret), true); } else { // Indicate that we want to reuse current auto-pin if present properties.put(CryptoTokenManagementSessionLocal.KEEP_AUTO_ACTIVATION_PIN, Boolean.TRUE.toString()); }
      }
      cryptoTokenManagementSession.saveCryptoToken(authenticationToken, getCurrentCryptoTokenId(), name, properties,
      secret);
      super.addNonTranslatedInfoMessage("CryptoToken saved successfully.");
      }
      flushCaches();
      setCurrentCryptoTokenEditMode(false);
      } catch (final Throwable e) { log.info("An error occurred when adding a new crypto token.", e); super.addNonTranslatedErrorMessage(e.getMessage()); }
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              bastianf Bastian Fredriksson
              Verified by:
              Henrik Sunmark
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Remaining Estimate - 1 day
                  1d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified