use of org.wso2.carbon.identity.sso.agent.saml.SSOAgentX509KeyStoreCredential in project identity-test-integration by wso2-incubator.
the class SampleContextEventListener method contextInitialized.
public void contextInitialized(ServletContextEvent servletContextEvent) {
properties = new Properties();
try {
if (servletContextEvent.getServletContext().getContextPath().contains("travelocity.com")) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/travelocity.properties"));
} else if (servletContextEvent.getServletContext().getContextPath().contains("avis.com")) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/avis.properties"));
} else {
String resourcePath = "/WEB-INF/classes" + servletContextEvent.getServletContext().getContextPath() + ".properties";
InputStream resourceStream = servletContextEvent.getServletContext().getResourceAsStream(resourcePath);
if (resourceStream != null) {
properties.load(servletContextEvent.getServletContext().getResourceAsStream(resourcePath));
}
}
InputStream keyStoreInputStream = servletContextEvent.getServletContext().getResourceAsStream("/WEB-INF/classes/wso2carbon.jks");
SSOAgentX509Credential credential = new SSOAgentX509KeyStoreCredential(keyStoreInputStream, properties.getProperty("KeyStorePassword").toCharArray(), properties.getProperty("IdPPublicCertAlias"), properties.getProperty("PrivateKeyAlias"), properties.getProperty("PrivateKeyPassword").toCharArray());
SSOAgentConfig config = new SSOAgentConfig();
config.initConfig(properties);
config.getSAML2().setSSOAgentX509Credential(credential);
config.getOpenId().setAttributesRequestor(new SampleAttributesRequestor());
servletContextEvent.getServletContext().setAttribute(SSOAgentConstants.CONFIG_BEAN_NAME, config);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
} catch (SSOAgentException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
Aggregations