Search in sources :

Example 1 with ConnectionTargetCheckEvaluator

use of won.auth.check.ConnectionTargetCheckEvaluator in project webofneeds by researchstudio-sat.

the class WonConnectionTargetCheckEvaluator method isRequestorAllowedTarget.

@Override
public boolean isRequestorAllowedTarget(ConnectionTargetCheck check) {
    boolean restrictsConnectionStates = isPresent(check.getAllowedConnectionStates());
    boolean restrictsSocketTypes = isPresent(check.getAllowedSocketTypes());
    boolean restrictsSockets = isPresent(check.getAllowedSockets());
    int rcs = restrictsConnectionStates ? RESTRICTS_CONNECTION_STATES : 0;
    int rst = restrictsSocketTypes ? RESTRICTS_SOCKET_TYPES : 0;
    int rs = restrictsSockets ? RESTRICTS_SOCKETS : 0;
    int wnc = check.isWonNodeCheck() ? WON_NODE_CHECK : 0;
    int evaluatorIndex = wnc | rcs | rst | rs;
    ConnectionTargetCheckEvaluator evaluator = evaluators[evaluatorIndex];
    if (logger.isDebugEnabled()) {
        logger.debug("Using evaluator with index {} (wnc:{}, rcs:{}, rst:{}, rs:{}) ", new Object[] { evaluatorIndex, wnc, restrictsConnectionStates, restrictsSocketTypes, restrictsSockets });
    }
    return evaluator.isRequestorAllowedTarget(check);
}
Also used : ConnectionTargetCheckEvaluator(won.auth.check.ConnectionTargetCheckEvaluator)

Aggregations

ConnectionTargetCheckEvaluator (won.auth.check.ConnectionTargetCheckEvaluator)1