[java-idp-testbed] 01/03: IDP-1008 - Rename request parameters
Tom Zeller
tzeller at dragonacea.biz
Thu Aug 4 20:06:05 EDT 2016
This is an automated email from the git hooks/post-receive script.
tzeller pushed a commit to branch master
in repository java-idp-testbed.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-testbed.git;a=commit;h=14cab726c40820726d06d43d3c5caa67351aa18b
commit 14cab726c40820726d06d43d3c5caa67351aa18b
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Thu Aug 4 17:04:24 2016 -0500
IDP-1008 - Rename request parameters
---
src/main/java/sp/SAML2Controller.java | 51 ++++++++++++++++++++---------------
src/main/webapp/index.html | 20 +++++++-------
2 files changed, 39 insertions(+), 32 deletions(-)
diff --git a/src/main/java/sp/SAML2Controller.java b/src/main/java/sp/SAML2Controller.java
index 266d696..d740f3c 100644
--- a/src/main/java/sp/SAML2Controller.java
+++ b/src/main/java/sp/SAML2Controller.java
@@ -560,25 +560,26 @@ public class SAML2Controller extends BaseSAMLController {
*/
@RequestMapping(value = "/AttributeQuery", method = RequestMethod.POST) public ResponseEntity<String>
initSAML2AttributeQuery(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
- @RequestParam("endpoint") String endpoint,
- @RequestParam("principalName") String principalName,
- @RequestParam("trustedCertificate") String trustedCertificate,
- @RequestParam("trustedCertificatePassword") String trustedCertificatePassword,
- @RequestParam("clientCertificate") String clientCertificate,
- @RequestParam("clientKey") String clientKey,
- @RequestParam("clientPassword") String clientPassword) throws Exception {
+ @RequestParam(value = "endpoint", required = true) String endpoint,
+ @RequestParam(value = "principalName", required = true) String principalName,
+ @RequestParam(value = "trustedTLSCertificate", required = true) String trustedTLSCertificate,
+ @RequestParam(value = "trustedTLSCertificatePassword", required = true) String trustedTLSCertificatePassword,
+ @RequestParam(value = "clientTLSCertificate", required = false) String clientTLSCertificate,
+ @RequestParam(value = "clientTLSPrivateKey", required = true) String clientTLSPrivateKey,
+ @RequestParam(value = "clientTLSPassword", required = true) String clientTLSPassword)
+ throws Exception {
- final Resource trustedCertificateResource = applicationContext.getResource(trustedCertificate);
- log.debug("SAML 2 AttributeQuery trusted certificate '{}'", trustedCertificateResource);
+ final Resource trustedTLSCertificateResource = applicationContext.getResource(trustedTLSCertificate);
+ log.debug("Trusted TLS certificate resource '{}'", trustedTLSCertificateResource);
- final Resource clientCertificateResource = applicationContext.getResource(clientCertificate);
- log.debug("SAML 2 AttributeQuery client certificate '{}'", clientCertificateResource);
+ final Resource clientTLSCertificateResource = applicationContext.getResource(clientTLSCertificate);
+ log.debug("Client TLS certificate resource '{}'", clientTLSCertificateResource);
- final Resource clientKeyResource = applicationContext.getResource(clientKey);
- log.debug("SAML 2 AttributeQuery client key '{}'", clientKeyResource);
+ final Resource clientTLSPrivateKeyResource = applicationContext.getResource(clientTLSPrivateKey);
+ log.debug("Client TLS private key resource '{}'", clientTLSPrivateKeyResource);
- final HttpClient httpClient = buildHttpClient(trustedCertificateResource, trustedCertificatePassword,
- clientCertificateResource, clientKeyResource, clientPassword);
+ final HttpClient httpClient = buildHttpClient(trustedTLSCertificateResource, trustedTLSCertificatePassword,
+ clientTLSCertificateResource, clientTLSPrivateKeyResource, clientTLSPassword);
final HttpSOAPClient httpSoapClient = new HttpSOAPClient();
httpSoapClient.setParserPool(parserPool);
@@ -665,21 +666,27 @@ public class SAML2Controller extends BaseSAMLController {
return inOutOpCtx;
}
- @Nonnull public HttpClient buildHttpClient(Resource trustedCertificate, String trustedCertificatePassword, Resource clientCertificate,
- Resource clientKey, String clientPassword) throws Exception {
+ @Nonnull public HttpClient buildHttpClient(@Nonnull final Resource trustedTLSCertificate,
+ @Nonnull final String trustedTLSCertificatePassword, @Nullable final Resource clientTLSCertificate,
+ @Nonnull final Resource clientTLSPrivateKey, @Nonnull final String clientTLSPassword) throws Exception {
final KeyStore trustStore = KeyStore.getInstance("PKCS12");
- trustStore.load(trustedCertificate.getInputStream(), trustedCertificatePassword.toCharArray());
+ trustStore.load(trustedTLSCertificate.getInputStream(), trustedTLSCertificatePassword.toCharArray());
+
+ final PrivateKey clientPrivateKey = KeyPairUtil.readPrivateKey(clientTLSPrivateKey.getInputStream());
+
+ X509Certificate clientCert = null;
+ if (clientTLSCertificate != null) {
+ clientCert = CertUtil.readCertificate(clientTLSCertificate.getInputStream());
+ }
- final PrivateKey clientPrivateKey = KeyPairUtil.readPrivateKey(clientKey.getInputStream());
- final X509Certificate clientCert = CertUtil.readCertificate(clientCertificate.getInputStream());
final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
- keyStore.setKeyEntry("sp", clientPrivateKey, clientPassword.toCharArray(), new Certificate[] {clientCert});
+ keyStore.setKeyEntry("sp", clientPrivateKey, clientTLSPassword.toCharArray(), new Certificate[] {clientCert});
final SSLContextBuilder sslContextBuilder = SSLContexts.custom();
sslContextBuilder.loadTrustMaterial(trustStore);
- sslContextBuilder.loadKeyMaterial(keyStore, clientPassword.toCharArray());
+ sslContextBuilder.loadKeyMaterial(keyStore, clientTLSPassword.toCharArray());
final SSLContext sslcontext = sslContextBuilder.build();
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index 138135f..0a8412d 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -200,24 +200,24 @@
<td><input id="saml2-attribute-query-principalName" name="principalName" value="jdoe" /></td>
</tr>
<tr>
- <td>trustedCertificate</td>
- <td><input id="saml2-attribute-query-trustedCertificate" name="trustedCertificate" value="classpath:/credentials/idp-backchannel.p12" size="60" /></td>
+ <td>trustedTLSCertificate</td>
+ <td><input id="saml2-attribute-query-trustedTLSCertificate" name="trustedTLSCertificate" value="classpath:/credentials/idp-backchannel.p12" size="90" /></td>
</tr>
<tr>
- <td>trustedCertificatePassword</td>
- <td><input id="saml2-attribute-query-trustedCertificatePassword" name="trustedCertificatePassword" value="changeit" size="20" /></td>
+ <td>trustedTLSCertificatePassword</td>
+ <td><input id="saml2-attribute-query-trustedTLSCertificatePassword" name="trustedTLSCertificatePassword" value="changeit" size="20" /></td>
</tr>
<tr>
- <td>clientCertificate</td>
- <td><input id="saml2-attribute-query-clientCertificate" name="clientCertificate" value="classpath:/credentials/sp.crt" size="60" /></td>
+ <td>clientTLSCertificate</td>
+ <td><input id="saml2-attribute-query-clientTLSCertificate" name="clientTLSCertificate" value="classpath:/credentials/sp.crt" size="90" /></td>
</tr>
<tr>
- <td>clientKey</td>
- <td><input id="saml2-attribute-query-clientKey" name="clientKey" value="classpath:/credentials/sp.key" size="60" /></td>
+ <td>clientTLSPrivateKey</td>
+ <td><input id="saml2-attribute-query-clientTLSPrivateKey" name="clientTLSPrivateKey" value="classpath:/credentials/sp.key" size="90" /></td>
</tr>
<tr>
- <td>clientPassword</td>
- <td><input id="saml2-attribute-query-clientPassword" name="clientPassword" value="secret" size="20" /></td>
+ <td>clientTLSPassword</td>
+ <td><input id="saml2-attribute-query-clientTLSPassword" name="clientTLSPassword" value="secret" size="20" /></td>
</tr>
</table>
<input type="submit" value="SAML2AttributeQuery">
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list