Histórico da Página
...
Bloco de código | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
package com.totalbanco.framework.josso.web; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.totalbanco.framework.orion.TBAppConfig; import com.totvslabs.idm.protocol.saml2toolkit.common.OpenSAMLInitializer; import com.totvslabs.idm.protocol.saml2toolkit.common.PropertyObject; import com.totvslabs.idm.protocol.saml2toolkit.common.User; import com.totvslabs.idm.protocol.saml2toolkit.responseVerify.ResponseProcessor; /** * This class will receive SAML response from the IDP * */ public class AssertionConsumerService extends HttpServlet { private final static Logger logger = LoggerFactory.getLogger(AssertionConsumerService.class); private static final long serialVersionUID = 1L; @Override public void init() { try { //initialize the library OpenSAMLInitializer initOpenSaml = new OpenSAMLInitializer(); initOpenSaml.initializeLibrary(); }catch (Exception e){ logger.error("Exception occurred while initializing the OpenSaml library: " + e.getMessage()); } } @Override public void doGet(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws ServletException, IOException { logger.debug("received a GET"); receiveResponse(httpRequest, httpResponse); } @Override public void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { logger.debug("received a POST"); receiveResponse(request, response); } private void receiveResponse(HttpServletRequest httpRequest, HttpServletResponse httpResponse) { logger.debug("receieved a SAML Response"); try { final TBAppConfig tbAppConfig = (TBAppConfig) httpRequest.getSession().getServletContext().getAttribute(TBAppConfig.COMPONENT_NAME); final PropertyObject propObj = new PropertyObject(); propObj.setClockSkew(tbAppConfig.getParametros().get("autenticacaoClockSkew")); propObj.setSpIssuerName(tbAppConfig.getParametros().get("autenticacaoSpIssuerName")); propObj.setSpProtocolBinding(tbAppConfig.getParametros().get("autenticacaoSpProtocolBinding")); propObj.setAcsUrl(tbAppConfig.getParametros().get("autenticacaoAcsURL")); propObj.setIdpProtocolBinding(tbAppConfig.getParametros().get("autenticacaoIdpProtocolBinding")); propObj.setProviderName(tbAppConfig.getParametros().get("autenticacaoProviderName")); propObj.setNameIdFormat(tbAppConfig.getParametros().get("autenticacaoNameIdFormat")); propObj.setRelayState(tbAppConfig.getParametros().get("autenticacaoRelayState")); propObj.setIdpIssuerName(tbAppConfig.getParametros().get("autenticacaoIdpIssuerName")); propObj.setIdpDestination(tbAppConfig.getParametros().get("autenticacaoIdpDestination")); propObj.setCertificateFile(tbAppConfig.getParametros().get("autenticacaoCertificateFile")); propObj.setIdpCertIssuerName(tbAppConfig.getParametros().get("autenticacaoIdpCertIssuerName")); logger.debug("ResponseProcessor.processResponse() will be executed with properties bellow:"); logger.debug("ClockSkew: " + propObj.getClockSkew()); logger.debug("SpIssuerName: " + propObj.getSpIssuerName()); logger.debug("SpProtocolBinding: " + propObj.getSpProtocolBinding()); logger.debug("AcsUrl: " + propObj.getAcsUrl()); logger.debug("IdpProtocolBinding: " + propObj.getIdpProtocolBinding()); logger.debug("ProviderName: " + propObj.getProviderName()); logger.debug("NameIdFormat: " + propObj.getNameIdFormat()); logger.debug("RelayState: " + propObj.getRelayState()); logger.debug("IdpIssuerName: " + propObj.getIdpIssuerName()); logger.debug("IdpDestination: " + propObj.getIdpDestination()); logger.debug("CertificateFile: " + propObj.getCertificateFile()); final ResponseProcessor responseProcessor = new ResponseProcessor(); final User user = responseProcessor.processResponse(httpRequest, httpResponse, propObj); logger.debug("Usuário autenticado: " + user.getUsername()); httpRequest.getSession(true).setAttribute("userFluig", user); httpResponse.sendRedirect(httpRequest.getContextPath() + "/signon/login.htm"); } catch(Exception e) { logger.error("Exception while processing the response: " + e.getMessage()); } } } |
Configurando
...
o TFS como Aplicação no Fluig Identity
Para que a aplicação o TFS possa usufruir do recurso de Single-Sign-On, é necessário cadastrá-la lo e configurá-la lo como uma Aplicação no Fluig Identity. Para isso adicione uma nova aplicação:
...
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas