@Test public void getPossibleTokenActionActivateOrDeactivate() { assertTrue(possibleActionsRuleEngine.getPossibleTokenActions( new TokenInfoBuilder() .available(true) .active(false) .build()) .contains(PossibleActionEnum.TOKEN_ACTIVATE)); assertFalse(possibleActionsRuleEngine.getPossibleTokenActions( new TokenInfoBuilder() .available(true) .active(true) .build()) .contains(PossibleActionEnum.TOKEN_ACTIVATE)); assertFalse(possibleActionsRuleEngine.getPossibleTokenActions( new TokenInfoBuilder() .available(false) .active(false) .build()) .contains(PossibleActionEnum.TOKEN_ACTIVATE)); assertTrue(possibleActionsRuleEngine.getPossibleTokenActions( new TokenInfoBuilder() .active(true) .build()) .contains(PossibleActionEnum.TOKEN_DEACTIVATE)); assertFalse(possibleActionsRuleEngine.getPossibleTokenActions( new TokenInfoBuilder() .active(false) .build()) .contains(PossibleActionEnum.TOKEN_DEACTIVATE)); assertTrue(possibleActionsRuleEngine.getPossibleTokenActions( new TokenInfoBuilder() .available(false) .active(true) .build()) .contains(PossibleActionEnum.TOKEN_DEACTIVATE)); }
public EnumSet<PossibleActionEnum> getPossibleTokenActions(TokenInfo tokenInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.GENERATE_KEY); } if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.TOKEN_DEACTIVATE); } else { if (tokenInfo.isAvailable()) { actions.add(PossibleActionEnum.TOKEN_ACTIVATE); } } if (tokenInfo.isSavedToConfiguration()) { actions.add(PossibleActionEnum.EDIT_FRIENDLY_NAME); } return actions; }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleTokenActions(TokenInfo tokenInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.GENERATE_KEY); } if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.TOKEN_DEACTIVATE); } else { if (tokenInfo.isAvailable()) { actions.add(PossibleActionEnum.TOKEN_ACTIVATE); } } if (tokenInfo.isSavedToConfiguration()) { actions.add(PossibleActionEnum.EDIT_FRIENDLY_NAME); } return actions; } }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleTokenActions(TokenInfo tokenInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.GENERATE_KEY); } if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.TOKEN_DEACTIVATE); } else { if (tokenInfo.isAvailable()) { actions.add(PossibleActionEnum.TOKEN_ACTIVATE); } } if (tokenInfo.isSavedToConfiguration()) { actions.add(PossibleActionEnum.EDIT_FRIENDLY_NAME); } return actions; }  }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleTokenActions(TokenInfo tokenInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.GENERATE_KEY); } if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.TOKEN_DEACTIVATE); } else { if (tokenInfo.isAvailable()) { actions.add(PossibleActionEnum.TOKEN_ACTIVATE); } } if (tokenInfo.isSavedToConfiguration()) { actions.add(PossibleActionEnum.EDIT_FRIENDLY_NAME); } 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> getPossibleTokenActions(TokenInfo tokenInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.GENERATE_KEY); } if (tokenInfo.isActive()) { actions.add(PossibleActionEnum.TOKEN_DEACTIVATE); } else { if (tokenInfo.isAvailable()) { actions.add(PossibleActionEnum.TOKEN_ACTIVATE); } } if (tokenInfo.isSavedToConfiguration()) { actions.add(PossibleActionEnum.EDIT_FRIENDLY_NAME); } 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; }