Changeset 67
- Timestamp:
- 01/25/07 14:54:56 (2 years ago)
- Files:
-
- AcmeIdp/trunk/web/recv-authnrequest.jsp (moved) (moved from AcmeIdp/trunk/web/idp-request.jsp) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
AcmeIdp/trunk/web/recv-authnrequest.jsp
r60 r67 8 8 9 9 <%@ page import="org.opensaml.*" %> 10 <%@ page import="org.opensaml.common.binding.BindingException" %> 10 11 <%@ page import="org.opensaml.common.xml.SAMLConstants" %> 11 12 <%@ page import="org.opensaml.xml.*" %> 12 13 <%@ page import="org.opensaml.xml.io.*" %> 14 <%@ page import="org.opensaml.saml2.binding.*" %> 13 15 <%@ page import="org.opensaml.saml2.core.*" %> 14 16 <%@ page import="org.opensaml.saml2.core.impl.*" %> … … 18 20 <%@ page import="org.w3c.dom.Document" %> 19 21 <%@ page import="org.w3c.dom.ls.DOMImplementationLS" %> 20 <%@ page import="org.w3c.dom.ls. LSSerializer" %>22 <%@ page import="org.w3c.dom.ls.*" %> 21 23 22 24 23 25 <% 24 String 25 relayState, 26 authnRequestXml; 27 byte [] tmp; 28 29 relayState = request.getParameter("RelayState"); // get the encoded AuthnRequest 30 31 // decode from base64 32 tmp = Base64.decodeBase64(relayState.getBytes()); 33 // convert to a string representation finally 34 authnRequestXml = new String(tmp); 35 26 // first bootstrap the entire opensaml library 36 27 org.opensaml.DefaultBootstrap.bootstrap(); 37 28 38 UnmarshallerFactory unmarshallerFactory = org.opensaml.Configuration.getUnmarshallerFactory(); 39 40 Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(auth); 29 String relayState; 30 HTTPPostDecoder decode = new HTTPPostDecoder(); 41 31 42 43 44 // Configuration.getConfiguration(); 32 try { 33 decode.setRequest(request); 34 decode.decode(); 35 relayState = decode.getRelayState(); 36 } catch (BindingException be) { 37 response.sendError(500, "No valid SAML 2.0 RelayState found in the request."); 38 return; 39 } 45 40 // Use the OpenSAML Configuration singleton to get a builder factory object 46 41 XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); 47 42 // First get a builder for AuthnRequest 48 43 AuthnRequestBuilder arb = (AuthnRequestBuilder) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME); 44 // build an AuthnRequest object 45 AuthnRequestImpl auth = (AuthnRequestImpl) arb.buildObject(); 46 47 auth = (AuthnRequestImpl) decode.getSAMLMessage(); 48 49 50 51 // UnmarshallerFactory unmarshallerFactory = org.opensaml.Configuration.getUnmarshallerFactory(); 52 53 // Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(doc); 54 55 56 /* 57 // Configuration.getConfiguration(); 49 58 // And one for Issuer 50 59 IssuerBuilder ib = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); 51 60 // And one for Subject 52 61 SubjectBuilder sb = (SubjectBuilder) builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME); 53 // build an AuthnRequest object54 AuthnRequestImpl auth = (AuthnRequestImpl) arb.buildObject();55 62 // Build the Issuer object 56 63 // Issuer newIssuer = ib.buildObject(SAMLConstants.SAML20_NS, "AcmeMLS", SAMLConstants.SAML20_PREFIX); … … 80 87 authElement = marshaller.marshall(auth); 81 88 } 82 83 DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); 84 85 DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); 86 87 LSSerializer writer = impl.createLSSerializer(); 88 String str = writer.writeToString(authElement); 89 str = str.replace("<", "<"); 90 str = str.replace(">", ">"); 89 */ 91 90 92 91 %> … … 106 105 <h1>ACME Idp AuthnRequest</h1> 107 106 <table> 108 <tr><td>auth: <% out.println( auth.toString() );%></td></tr>109 <tr><td>newIssuer: <% out.println( newIssuer.toString() );%></td></tr>110 <tr><td>authElement: <% if (authElement != null) out.println( authElement.toString() );%></td></tr>111 <tr><td>msg <% out.println( msg );%></td></tr>112 <tr><td>str <% out.println( str );%> </td></tr>107 <tr><td>auth: <% //out.println( auth.toString() );%></td></tr> 108 <tr><td>newIssuer: <% //out.println( newIssuer.toString() );%></td></tr> 109 <tr><td>authElement: <% //if (authElement != null) out.println( authElement.toString() );%></td></tr> 110 <tr><td>msg <% //out.println( msg );%></td></tr> 111 <tr><td>str <% //out.println( str );%> </td></tr> 113 112 114 113 </table>
