Changeset 67

Show
Ignore:
Timestamp:
01/25/07 14:54:56 (2 years ago)
Author:
paulhethmon
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • AcmeIdp/trunk/web/recv-authnrequest.jsp

    r60 r67  
    88 
    99<%@ page import="org.opensaml.*" %> 
     10<%@ page import="org.opensaml.common.binding.BindingException" %> 
    1011<%@ page import="org.opensaml.common.xml.SAMLConstants" %> 
    1112<%@ page import="org.opensaml.xml.*" %> 
    1213<%@ page import="org.opensaml.xml.io.*" %> 
     14<%@ page import="org.opensaml.saml2.binding.*" %> 
    1315<%@ page import="org.opensaml.saml2.core.*" %> 
    1416<%@ page import="org.opensaml.saml2.core.impl.*" %> 
     
    1820<%@ page import="org.w3c.dom.Document" %> 
    1921<%@ page import="org.w3c.dom.ls.DOMImplementationLS" %> 
    20 <%@ page import="org.w3c.dom.ls.LSSerializer" %> 
     22<%@ page import="org.w3c.dom.ls.*" %> 
    2123 
    2224 
    2325<% 
    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 
    3627  org.opensaml.DefaultBootstrap.bootstrap(); 
    3728   
    38   UnmarshallerFactory unmarshallerFactory = org.opensaml.Configuration.getUnmarshallerFactory(); 
    39      
    40   Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(auth); 
     29  String relayState; 
     30  HTTPPostDecoder decode = new HTTPPostDecoder(); 
    4131   
    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  } 
    4540    // Use the OpenSAML Configuration singleton to get a builder factory object 
    4641    XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); 
    4742    // First get a builder for AuthnRequest 
    4843    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(); 
    4958    // And one for Issuer 
    5059    IssuerBuilder ib = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); 
    5160    // And one for Subject 
    5261    SubjectBuilder sb = (SubjectBuilder) builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME); 
    53     // build an AuthnRequest object 
    54     AuthnRequestImpl auth = (AuthnRequestImpl) arb.buildObject(); 
    5562    // Build the Issuer object 
    5663//    Issuer newIssuer = ib.buildObject(SAMLConstants.SAML20_NS, "AcmeMLS", SAMLConstants.SAML20_PREFIX); 
     
    8087      authElement = marshaller.marshall(auth); 
    8188    } 
    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("<", "&lt;"); 
    90   str = str.replace(">", "&gt;"); 
     89*/ 
    9190     
    9291%>     
     
    106105    <h1>ACME Idp AuthnRequest</h1> 
    107106    <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> 
    113112 
    114113    </table>