@Test public void getPossibleKeyActionDelete() { EnumSet<PossibleActionEnum> actions = getPossibleKeyActions( createTestToken(true, false, true, false)); assertTrue(actions.contains(PossibleActionEnum.DELETE)); actions = getPossibleKeyActions( createTestToken(true, false, true, true)); assertFalse(actions.contains(PossibleActionEnum.DELETE)); actions = getPossibleKeyActions( createTestToken(false, false, false, false)); assertFalse(actions.contains(PossibleActionEnum.DELETE)); actions = getPossibleKeyActions( createTestToken(false, true, true, false)); assertFalse(actions.contains(PossibleActionEnum.DELETE)); actions = getPossibleKeyActions( createTestToken(true, false, false, false)); assertFalse(actions.contains(PossibleActionEnum.DELETE)); }
public EnumSet<PossibleActionEnum> getPossibleKeyActions(TokenInfo tokenInfo, KeyInfo keyInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean keyNotSupported = isKeyUnsupported(tokenInfo, keyInfo); if (tokenInfo.isActive() && !keyNotSupported && !(tokenInfo.isReadOnly() && !keyInfo.isSavedToConfiguration()) && (keyInfo.isSavedToConfiguration() || tokenInfo.isActive())) { actions.add(PossibleActionEnum.DELETE); } if (SOFTWARE_TOKEN_ID.equals(tokenInfo.getId()) && (keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_AUTH_CSR); } if ((keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.SIGNING) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_SIGN_CSR); } actions.add(PossibleActionEnum.EDIT_FRIENDLY_NAME); return actions; }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleKeyActions(TokenInfo tokenInfo, KeyInfo keyInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean keyNotSupported = isKeyUnsupported(tokenInfo, keyInfo); if (tokenInfo.isActive() && !keyNotSupported && !(tokenInfo.isReadOnly() && !keyInfo.isSavedToConfiguration()) && (keyInfo.isSavedToConfiguration() || tokenInfo.isActive())) { actions.add(PossibleActionEnum.DELETE); } if (SOFTWARE_TOKEN_ID.equals(tokenInfo.getId()) && (keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_AUTH_CSR); } if ((keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.SIGNING) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_SIGN_CSR); } actions.add(PossibleActionEnum.EDIT_FRIENDLY_NAME); return actions; } }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleKeyActions(TokenInfo tokenInfo, KeyInfo keyInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean keyNotSupported = isKeyUnsupported(tokenInfo, keyInfo); if (tokenInfo.isActive() && !keyNotSupported && !(tokenInfo.isReadOnly() && !keyInfo.isSavedToConfiguration()) && (keyInfo.isSavedToConfiguration() || tokenInfo.isActive())) { actions.add(PossibleActionEnum.DELETE); } if (SOFTWARE_TOKEN_ID.equals(tokenInfo.getId()) && (keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_AUTH_CSR); } if ((keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.SIGNING) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_SIGN_CSR); } actions.add(PossibleActionEnum.EDIT_FRIENDLY_NAME); return actions; }  }
PossibleActionsRuleEngine { public EnumSet<PossibleActionEnum> getPossibleKeyActions(TokenInfo tokenInfo, KeyInfo keyInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean keyNotSupported = isKeyUnsupported(tokenInfo, keyInfo); if (tokenInfo.isActive() && !keyNotSupported && !(tokenInfo.isReadOnly() && !keyInfo.isSavedToConfiguration()) && (keyInfo.isSavedToConfiguration() || tokenInfo.isActive())) { actions.add(PossibleActionEnum.DELETE); } if (SOFTWARE_TOKEN_ID.equals(tokenInfo.getId()) && (keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_AUTH_CSR); } if ((keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.SIGNING) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_SIGN_CSR); } 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> getPossibleKeyActions(TokenInfo tokenInfo, KeyInfo keyInfo) { EnumSet<PossibleActionEnum> actions = EnumSet.noneOf(PossibleActionEnum.class); boolean keyNotSupported = isKeyUnsupported(tokenInfo, keyInfo); if (tokenInfo.isActive() && !keyNotSupported && !(tokenInfo.isReadOnly() && !keyInfo.isSavedToConfiguration()) && (keyInfo.isSavedToConfiguration() || tokenInfo.isActive())) { actions.add(PossibleActionEnum.DELETE); } if (SOFTWARE_TOKEN_ID.equals(tokenInfo.getId()) && (keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.AUTHENTICATION) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_AUTH_CSR); } if ((keyInfo.getUsage() == null || keyInfo.getUsage() == KeyUsageInfo.SIGNING) && !(!keyInfo.isAvailable() || !tokenInfo.isActive() || keyNotSupported)) { actions.add(PossibleActionEnum.GENERATE_SIGN_CSR); } 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; }