@Test public void getPossibleCertificateActionActivate() { assertTrue(possibleActionsRuleEngine.getPossibleCertificateActions( new TokenInfoBuilder().build(), new KeyInfoBuilder().build(), new CertificateInfoBuilder() .active(false) .savedToConfiguration(true).build()) .contains(PossibleActionEnum.ACTIVATE)); assertFalse(possibleActionsRuleEngine.getPossibleCertificateActions( new TokenInfoBuilder().build(), new KeyInfoBuilder().build(), new CertificateInfoBuilder() .active(true) .savedToConfiguration(true).build()) .contains(PossibleActionEnum.ACTIVATE)); assertFalse(possibleActionsRuleEngine.getPossibleCertificateActions( new TokenInfoBuilder().build(), new KeyInfoBuilder().build(), new CertificateInfoBuilder() .active(false) .savedToConfiguration(false).build()) .contains(PossibleActionEnum.ACTIVATE)); }
public EnumSet<PossibleActionEnum> getPossibleCertificateActions(TokenInfo tokenInfo, KeyInfo keyInfo, CertificateInfo certificateInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean canUnregister = keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && (CertificateInfo.STATUS_REGINPROG.equals(certificateInfo.getStatus()) || CertificateInfo.STATUS_REGISTERED.equals(certificateInfo.getStatus())); if (canUnregister) { actions.add(PossibleActionEnum.UNREGISTER); } boolean savedToConfiguration = certificateInfo.isSavedToConfiguration(); if (canDeleteCertOrCsr(tokenInfo, savedToConfiguration, canUnregister)) { actions.add(PossibleActionEnum.DELETE); } if (keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && CertificateInfo.STATUS_SAVED.equals(certificateInfo.getStatus()) && (!canUnregister)) { actions.add(PossibleActionEnum.REGISTER); } if (keyInfo.getUsage() != null && certificateInfo.isSavedToConfiguration()) { if (certificateInfo.isActive()) { actions.add(PossibleActionEnum.DISABLE); } else { actions.add(PossibleActionEnum.ACTIVATE); } } if (!certificateInfo.isSavedToConfiguration()) { if (!isAuthCert(certificateInfo)) { actions.add(PossibleActionEnum.IMPORT_FROM_TOKEN); } } return actions; }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleCertificateActions(TokenInfo tokenInfo, KeyInfo keyInfo, CertificateInfo certificateInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean canUnregister = keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && (CertificateInfo.STATUS_REGINPROG.equals(certificateInfo.getStatus()) || CertificateInfo.STATUS_REGISTERED.equals(certificateInfo.getStatus())); if (canUnregister) { actions.add(PossibleActionEnum.UNREGISTER); } boolean savedToConfiguration = certificateInfo.isSavedToConfiguration(); if (canDeleteCertOrCsr(tokenInfo, savedToConfiguration, canUnregister)) { actions.add(PossibleActionEnum.DELETE); } if (keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && CertificateInfo.STATUS_SAVED.equals(certificateInfo.getStatus()) && (!canUnregister)) { actions.add(PossibleActionEnum.REGISTER); } if (keyInfo.getUsage() != null && certificateInfo.isSavedToConfiguration()) { if (certificateInfo.isActive()) { actions.add(PossibleActionEnum.DISABLE); } else { actions.add(PossibleActionEnum.ACTIVATE); } } if (!certificateInfo.isSavedToConfiguration()) { if (!isAuthCert(certificateInfo)) { actions.add(PossibleActionEnum.IMPORT_FROM_TOKEN); } } return actions; } }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleCertificateActions(TokenInfo tokenInfo, KeyInfo keyInfo, CertificateInfo certificateInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean canUnregister = keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && (CertificateInfo.STATUS_REGINPROG.equals(certificateInfo.getStatus()) || CertificateInfo.STATUS_REGISTERED.equals(certificateInfo.getStatus())); if (canUnregister) { actions.add(PossibleActionEnum.UNREGISTER); } boolean savedToConfiguration = certificateInfo.isSavedToConfiguration(); if (canDeleteCertOrCsr(tokenInfo, savedToConfiguration, canUnregister)) { actions.add(PossibleActionEnum.DELETE); } if (keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && CertificateInfo.STATUS_SAVED.equals(certificateInfo.getStatus()) && (!canUnregister)) { actions.add(PossibleActionEnum.REGISTER); } if (keyInfo.getUsage() != null && certificateInfo.isSavedToConfiguration()) { if (certificateInfo.isActive()) { actions.add(PossibleActionEnum.DISABLE); } else { actions.add(PossibleActionEnum.ACTIVATE); } } if (!certificateInfo.isSavedToConfiguration()) { if (!isAuthCert(certificateInfo)) { actions.add(PossibleActionEnum.IMPORT_FROM_TOKEN); } } return actions; }  }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleCertificateActions(TokenInfo tokenInfo, KeyInfo keyInfo, CertificateInfo certificateInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean canUnregister = keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && (CertificateInfo.STATUS_REGINPROG.equals(certificateInfo.getStatus()) || CertificateInfo.STATUS_REGISTERED.equals(certificateInfo.getStatus())); if (canUnregister) { actions.add(PossibleActionEnum.UNREGISTER); } boolean savedToConfiguration = certificateInfo.isSavedToConfiguration(); if (canDeleteCertOrCsr(tokenInfo, savedToConfiguration, canUnregister)) { actions.add(PossibleActionEnum.DELETE); } if (keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && CertificateInfo.STATUS_SAVED.equals(certificateInfo.getStatus()) && (!canUnregister)) { actions.add(PossibleActionEnum.REGISTER); } if (keyInfo.getUsage() != null && certificateInfo.isSavedToConfiguration()) { if (certificateInfo.isActive()) { actions.add(PossibleActionEnum.DISABLE); } else { actions.add(PossibleActionEnum.ACTIVATE); } } if (!certificateInfo.isSavedToConfiguration()) { if (!isAuthCert(certificateInfo)) { actions.add(PossibleActionEnum.IMPORT_FROM_TOKEN); } } return actions; }  EnumSet<PossibleActionEnum> getPossibleTokenActions(TokenInfo tokenInfo); boolean isKeyUnsupported(TokenInfo tokenInfo, KeyInfo keyInfo); EnumSet<PossibleActionEnum> getPossibleKeyActions(TokenInfo tokenInfo,
            KeyInfo keyInfo); EnumSet<PossibleActionEnum> getPossibleCertificateActions(TokenInfo tokenInfo,
            KeyInfo keyInfo,
            CertificateInfo certificateInfo); EnumSet<PossibleActionEnum> getPossibleCsrActions(TokenInfo tokenInfo); void requirePossibleAction(PossibleActionEnum action, EnumSet<PossibleActionEnum> possibleActions); void requirePossibleTokenAction(PossibleActionEnum action, TokenInfo tokenInfo); void requirePossibleKeyAction(PossibleActionEnum action, TokenInfo tokenInfo, KeyInfo keyInfo); void requirePossibleCertificateAction(PossibleActionEnum action, TokenInfo tokenInfo, KeyInfo keyInfo,
            CertificateInfo certificateInfo); void requirePossibleCsrAction(PossibleActionEnum action, TokenInfo tokenInfo, KeyInfo keyInfo,
            CertRequestInfo certRequestInfo); void requirePossibleAction(PossibleActionEnum action, ActionTargetType target,
            TokenInfo tokenInfo, KeyInfo keyInfo, CertificateInfo certificateInfo, CertRequestInfo certRequestInfo); }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleCertificateActions(TokenInfo tokenInfo, KeyInfo keyInfo, CertificateInfo certificateInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean canUnregister = keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && (CertificateInfo.STATUS_REGINPROG.equals(certificateInfo.getStatus()) || CertificateInfo.STATUS_REGISTERED.equals(certificateInfo.getStatus())); if (canUnregister) { actions.add(PossibleActionEnum.UNREGISTER); } boolean savedToConfiguration = certificateInfo.isSavedToConfiguration(); if (canDeleteCertOrCsr(tokenInfo, savedToConfiguration, canUnregister)) { actions.add(PossibleActionEnum.DELETE); } if (keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION && CertificateInfo.STATUS_SAVED.equals(certificateInfo.getStatus()) && (!canUnregister)) { actions.add(PossibleActionEnum.REGISTER); } if (keyInfo.getUsage() != null && certificateInfo.isSavedToConfiguration()) { if (certificateInfo.isActive()) { actions.add(PossibleActionEnum.DISABLE); } else { actions.add(PossibleActionEnum.ACTIVATE); } } if (!certificateInfo.isSavedToConfiguration()) { if (!isAuthCert(certificateInfo)) { actions.add(PossibleActionEnum.IMPORT_FROM_TOKEN); } } return actions; }  EnumSet<PossibleActionEnum> getPossibleTokenActions(TokenInfo tokenInfo); boolean isKeyUnsupported(TokenInfo tokenInfo, KeyInfo keyInfo); EnumSet<PossibleActionEnum> getPossibleKeyActions(TokenInfo tokenInfo,
            KeyInfo keyInfo); EnumSet<PossibleActionEnum> getPossibleCertificateActions(TokenInfo tokenInfo,
            KeyInfo keyInfo,
            CertificateInfo certificateInfo); EnumSet<PossibleActionEnum> getPossibleCsrActions(TokenInfo tokenInfo); void requirePossibleAction(PossibleActionEnum action, EnumSet<PossibleActionEnum> possibleActions); void requirePossibleTokenAction(PossibleActionEnum action, TokenInfo tokenInfo); void requirePossibleKeyAction(PossibleActionEnum action, TokenInfo tokenInfo, KeyInfo keyInfo); void requirePossibleCertificateAction(PossibleActionEnum action, TokenInfo tokenInfo, KeyInfo keyInfo,
            CertificateInfo certificateInfo); void requirePossibleCsrAction(PossibleActionEnum action, TokenInfo tokenInfo, KeyInfo keyInfo,
            CertRequestInfo certRequestInfo); void requirePossibleAction(PossibleActionEnum action, ActionTargetType target,
            TokenInfo tokenInfo, KeyInfo keyInfo, CertificateInfo certificateInfo, CertRequestInfo certRequestInfo); static final String SOFTWARE_TOKEN_ID; }