@Override
  public RegisteredServiceAccessStrategy toAccessStrategy(final ServiceData bean) {
    final RegisteredServiceSupportAccessEditBean supportAccess = bean.getSupportAccess();

    final TimeBasedRegisteredServiceAccessStrategy accessStrategy =
        new TimeBasedRegisteredServiceAccessStrategy();

    accessStrategy.setEnabled(supportAccess.isCasEnabled());
    accessStrategy.setSsoEnabled(supportAccess.isSsoEnabled());
    accessStrategy.setRequireAllAttributes(supportAccess.isRequireAll());

    final Map<String, Set<String>> requiredAttrs = supportAccess.getRequiredAttr();
    final Set<Map.Entry<String, Set<String>>> entries = requiredAttrs.entrySet();
    final Iterator<Map.Entry<String, Set<String>>> it = entries.iterator();
    while (it.hasNext()) {
      final Map.Entry<String, Set<String>> entry = it.next();
      if (entry.getValue().isEmpty()) {
        it.remove();
      }
    }
    accessStrategy.setRequiredAttributes(requiredAttrs);

    accessStrategy.setEndingDateTime(supportAccess.getEndingTime());
    accessStrategy.setStartingDateTime(supportAccess.getStartingTime());
    return accessStrategy;
  }
  @Override
  public void mapAccessStrategy(
      final RegisteredServiceAccessStrategy accessStrategy, final ServiceData bean) {
    final RegisteredServiceSupportAccessEditBean accessBean = bean.getSupportAccess();
    accessBean.setCasEnabled(accessStrategy.isServiceAccessAllowed());
    accessBean.setSsoEnabled(accessStrategy.isServiceAccessAllowedForSso());

    if (accessStrategy instanceof DefaultRegisteredServiceAccessStrategy) {
      final DefaultRegisteredServiceAccessStrategy def =
          (DefaultRegisteredServiceAccessStrategy) accessStrategy;
      accessBean.setRequireAll(def.isRequireAllAttributes());
      accessBean.setRequiredAttr(def.getRequiredAttributes());
    }

    if (accessStrategy instanceof TimeBasedRegisteredServiceAccessStrategy) {
      final TimeBasedRegisteredServiceAccessStrategy def =
          (TimeBasedRegisteredServiceAccessStrategy) accessStrategy;
      accessBean.setStartingTime(def.getStartingDateTime());
      accessBean.setEndingTime(def.getEndingDateTime());
    }
  }