diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2014-05-09 08:33:13 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2014-05-09 08:33:13 +0200 |
commit | a262c83730f2a50c41682226b53a6a82a937db7c (patch) | |
tree | c642a43cc0c4a0cca857aa4a6890b7185f2d2b27 /id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder | |
parent | bac9aefddd711fea0234144678fcd2f7dc624574 (diff) | |
download | moa-id-spss-a262c83730f2a50c41682226b53a6a82a937db7c.tar.gz moa-id-spss-a262c83730f2a50c41682226b53a6a82a937db7c.tar.bz2 moa-id-spss-a262c83730f2a50c41682226b53a6a82a937db7c.zip |
add MOA SOAP client
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder')
-rw-r--r-- | id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java | 55 |
1 files changed, 6 insertions, 49 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java index a1a51f6c1..792b6cdd7 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/AuthenticationDataBuilder.java @@ -32,19 +32,13 @@ import java.util.List; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; -import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; import org.opensaml.saml2.core.Assertion; import org.opensaml.saml2.core.Attribute; import org.opensaml.saml2.core.AttributeQuery; import org.opensaml.saml2.core.AttributeStatement; import org.opensaml.saml2.core.Response; -import org.opensaml.ws.soap.client.BasicSOAPMessageContext; -import org.opensaml.ws.soap.client.http.HttpClientBuilder; -import org.opensaml.ws.soap.client.http.HttpSOAPClient; import org.opensaml.ws.soap.common.SOAPException; -import org.opensaml.ws.soap.soap11.Body; -import org.opensaml.ws.soap.soap11.Envelope; -import org.opensaml.xml.parse.BasicParserPool; +import org.opensaml.xml.XMLObject; import org.opensaml.xml.security.SecurityException; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -62,12 +56,9 @@ import at.gv.egovernment.moa.id.auth.exception.ParseException; import at.gv.egovernment.moa.id.auth.exception.WrongParametersException; import at.gv.egovernment.moa.id.auth.parser.IdentityLinkAssertionParser; import at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils; -import at.gv.egovernment.moa.id.commons.db.dao.config.ChainingModeType; import at.gv.egovernment.moa.id.commons.db.dao.session.InterfederationSessionStore; import at.gv.egovernment.moa.id.commons.db.dao.session.OASessionStore; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; -import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException; -import at.gv.egovernment.moa.id.commons.utils.MOAHttpProtocolSocketFactory; import at.gv.egovernment.moa.id.config.ConfigurationException; import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; import at.gv.egovernment.moa.id.config.auth.IOAAuthParameters; @@ -82,7 +73,7 @@ import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.AssertionAttributeExt import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.AssertionValidationExeption; import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.AttributQueryException; import at.gv.egovernment.moa.id.protocols.pvp2x.messages.MOARequest; -import at.gv.egovernment.moa.id.protocols.pvp2x.utils.SAML2Utils; +import at.gv.egovernment.moa.id.protocols.pvp2x.utils.MOASAMLSOAPClient; import at.gv.egovernment.moa.id.protocols.pvp2x.verification.SAMLVerificationEngine; import at.gv.egovernment.moa.id.protocols.pvp2x.verification.TrustEngineFactory; import at.gv.egovernment.moa.id.protocols.saml1.SAML1AuthenticationData; @@ -268,50 +259,16 @@ public class AuthenticationDataBuilder implements MOAIDAuthConstants { AttributQueryBuilder.buildAttributQueryRequest(interfIDP.getUserNameID(), endpoint, attributs); //build SOAP request - BasicParserPool parserPool = new BasicParserPool(); - parserPool.setNamespaceAware(true); - - Envelope soapRequest = SAML2Utils.buildSOAP11Envelope(query); - - BasicSOAPMessageContext soapContext = new BasicSOAPMessageContext(); - soapContext.setOutboundMessage(soapRequest); - - HttpClientBuilder clientBuilder = new HttpClientBuilder(); - if (endpoint.startsWith("https")) { - try { - SecureProtocolSocketFactory sslprotocolsocketfactory = - new MOAHttpProtocolSocketFactory( - PVPConstants.SSLSOCKETFACTORYNAME, - AuthConfigurationProvider.getInstance().getCertstoreDirectory(), - AuthConfigurationProvider.getInstance().getTrustedCACertificates(), - null, - ChainingModeType.fromValue(AuthConfigurationProvider.getInstance().getDefaultChainingMode()), - AuthConfigurationProvider.getInstance().isTrustmanagerrevoationchecking()); - clientBuilder.setHttpsProtocolSocketFactory(sslprotocolsocketfactory ); - - } catch (MOAHttpProtocolSocketFactoryException e) { - Logger.warn("MOA SSL-TrustStore can not initialized. Use default Java TrustStore."); - - } - } - - HttpSOAPClient soapClient = new HttpSOAPClient(clientBuilder.buildClient(), parserPool); + List<XMLObject> xmlObjects = MOASAMLSOAPClient.send(endpoint, query); - //send request to IDP - soapClient.send(endpoint, soapContext); - - //parse response - Envelope soapResponse = (Envelope) soapContext.getInboundMessage(); - Body soapBody = soapResponse.getBody(); - - if (soapBody.getUnknownXMLObjects().size() == 0) { + if (xmlObjects.size() == 0) { Logger.error("Receive emptry AttributeQuery response-body."); throw new AttributQueryException("Receive emptry AttributeQuery response-body.", null); } - if (soapBody.getUnknownXMLObjects().get(0) instanceof Response) { - Response intfResp = (Response) soapBody.getUnknownXMLObjects().get(0); + if (xmlObjects.get(0) instanceof Response) { + Response intfResp = (Response) xmlObjects.get(0); //validate PVP 2.1 response try { |