| | |
| | | |
| | | /** The class represents the ssf keyword in a bind rule.SSF stands for security strength factor. */ |
| | | public class SSF implements KeywordBindRule { |
| | | /** Enumeration representing the bind rule operation type. */ |
| | | private EnumBindRuleType type; |
| | | |
| | | private static final int MAX_KEY_BITS=1024; |
| | | private int ssf; |
| | | |
| | | /** Enumeration representing the bind rule operation type. */ |
| | | private final EnumBindRuleType type; |
| | | private final int ssf; |
| | | |
| | | private SSF(int ssf, EnumBindRuleType type) { |
| | | this.ssf = ssf; |
| | |
| | | throw new AciException(message); |
| | | } |
| | | if (valueAsInt <= 0 || valueAsInt > MAX_KEY_BITS) { |
| | | LocalizableMessage message = WARN_ACI_SYNTAX_INVALID_SSF_RANGE.get(expr); |
| | | throw new AciException(message); |
| | | throw new AciException(WARN_ACI_SYNTAX_INVALID_SSF_RANGE.get(expr)); |
| | | } |
| | | return new SSF(valueAsInt, type); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public EnumEvalResult evaluate(AciEvalContext evalCtx) { |
| | | int currentSSF = evalCtx.getCurrentSSF(); |
| | | EnumEvalResult matched = getMatched(currentSSF); |
| | | EnumEvalResult matched = getMatched(evalCtx.getCurrentSSF()); |
| | | return matched.getRet(type, false); |
| | | } |
| | | |
| | | private EnumEvalResult getMatched(int currentSSF) { |
| | | return getMatched0(currentSSF) ? EnumEvalResult.TRUE : EnumEvalResult.FALSE; |
| | | } |
| | | |
| | | private boolean getMatched0(int currentSSF) |
| | | { |
| | | switch (type) { |
| | | case EQUAL_BINDRULE_TYPE: |
| | | case NOT_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF == ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | |
| | | return currentSSF == ssf; |
| | | case LESS_OR_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF <= ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | |
| | | return currentSSF <= ssf; |
| | | case LESS_BINDRULE_TYPE: |
| | | if (currentSSF < ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | |
| | | return currentSSF < ssf; |
| | | case GREATER_OR_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF >= ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | |
| | | return currentSSF >= ssf; |
| | | case GREATER_BINDRULE_TYPE: |
| | | if (currentSSF > ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | return currentSSF > ssf; |
| | | default: |
| | | return false; |
| | | } |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | | |
| | | @Override |