Ejemplo n.º 1
2
  protected void initializeHandlerChain(PicketLinkType picketLinkType) throws Exception {
    SAML2HandlerChain handlerChain;

    // Get the chain from config
    if (isNullOrEmpty(samlHandlerChainClass)) {
      handlerChain = SAML2HandlerChainFactory.createChain();
    } else {
      try {
        handlerChain = SAML2HandlerChainFactory.createChain(this.samlHandlerChainClass);
      } catch (ProcessingException e1) {
        throw new RuntimeException(e1);
      }
    }

    Handlers handlers = picketLinkType.getHandlers();

    if (handlers == null) {
      // Get the handlers
      String handlerConfigFileName = GeneralConstants.HANDLER_CONFIG_FILE_LOCATION;
      handlers =
          ConfigurationUtil.getHandlers(servletContext.getResourceAsStream(handlerConfigFileName));
    }

    picketLinkType.setHandlers(handlers);

    handlerChain.addAll(HandlerUtil.getHandlers(handlers));

    populateChainConfig(picketLinkType);
    SAML2HandlerChainConfig handlerChainConfig =
        new DefaultSAML2HandlerChainConfig(chainConfigOptions);

    Set<SAML2Handler> samlHandlers = handlerChain.handlers();

    for (SAML2Handler handler : samlHandlers) {
      handler.initChainConfig(handlerChainConfig);
    }

    chain = handlerChain;
  }