예제 #1
0
  @Override
  public void init(FilterConfig filterConfig) throws ServletException {
    String capsParam = filterConfig.getInitParameter(CAPABILITIES_PARAMETER);
    if (capsParam != null) {
      for (String nego : capsParam.trim().split(" *\\| *")) {
        try {
          caps |= Authn.Capabilities.class.getField(nego).getLong(null);
        } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException ex) {
          log.error("Error calculating authn capabilities while accessing constant  {}", nego);
        }
      }
    }

    AuthenticationProfileRepository.getInstance()
        .addObserver(
            new Observer() {
              @Override
              public void update(Observable o, Object arg) {
                cacheNegotiatingProfiles();
              }
            });
    cacheNegotiatingProfiles();
  }
예제 #2
0
  private synchronized void cacheNegotiatingProfiles() {
    schemes = new ArrayList<>();
    profiles = new ArrayList<>();

    for (AuthenticationProfile profile :
        AuthenticationProfileRepository.getInstance().getProfiles()) {
      ExtMap authnContext = profile.getAuthn().getContext();
      if ((authnContext.<Long>get(Authn.ContextKeys.CAPABILITIES).longValue() & caps) != 0) {
        profiles.add(profile);
        schemes.addAll(
            authnContext.<Collection<String>>get(
                Authn.ContextKeys.HTTP_AUTHENTICATION_SCHEME, Collections.<String>emptyList()));
      }
    }

    Collections.sort(
        profiles,
        new Comparator<AuthenticationProfile>() {
          @Override
          public int compare(AuthenticationProfile o1, AuthenticationProfile o2) {
            return Integer.compare(o1.getNegotiationPriority(), o2.getNegotiationPriority());
          }
        });
  }