Changeset 137

Show
Ignore:
Timestamp:
04/24/07 16:14:05 (2 years ago)
Author:
paulhethmon
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • AcmeIdp/trunk/web/include.jsp

    r58 r137  
    33String 
    44  _credentials = "credentials", 
    5   _loginerror = "loginerror"; 
     5  _loginerror = "loginerror", 
     6  _relaystate = "relaystate", 
     7  _authnrequest = "authnrequest"; 
    68 
    79 
  • AcmeIdp/trunk/web/login.jsp

    r60 r137  
    33<%@page session="true"%> 
    44<%@include file="include.jsp"%> 
     5 
     6<%@ page import="org.joda.time.DateTime" %> 
     7 
     8<%@ page import="org.opensaml.*" %> 
     9<%@ page import="org.opensaml.common.binding.BindingException" %> 
     10<%@ page import="org.opensaml.common.xml.SAMLConstants" %> 
     11<%@ page import="org.opensaml.saml2.binding.*" %> 
     12<%@ page import="org.opensaml.saml2.core.*" %> 
     13<%@ page import="org.opensaml.saml2.core.impl.*" %> 
     14<%@ page import="org.opensaml.xml.*" %> 
     15<%@ page import="org.opensaml.xml.parse.ParserPool" %> 
     16<%@ page import="org.opensaml.xml.io.*" %> 
     17<%@ page import="org.opensaml.xml.util.Base64" %> 
     18<%@ page import="org.opensaml.xml.util.XMLHelper" %> 
     19 
     20<%@ page import="org.w3c.dom.Element" %> 
    521<% 
    622    String  
     
    2238    } 
    2339     
     40    // Ok, if we are here, they have successfully authenticated, now check and 
     41    // see if we redirect them back to a SP 
     42    String relayState; 
     43     
     44    relayState = (String) session.getAttribute(_relaystate); 
     45    if (relayState != null) { // Ok, we have one 
     46      // first bootstrap the entire opensaml library 
     47      org.opensaml.DefaultBootstrap.bootstrap(); 
     48      // Use the OpenSAML Configuration singleton to get a builder factory object 
     49      XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); 
     50       
     51       
     52      AuthnRequestImpl auth = (AuthnRequestImpl) session.getAttribute(_authnrequest); 
     53      // we must now build the Response object to redirect the user back to the SP with 
     54      ResponseBuilder rspBldr = (ResponseBuilder) builderFactory.getBuilder(Response.DEFAULT_ELEMENT_NAME); 
     55      Response rsp = rspBldr.buildObject(); 
     56       
     57      rsp.setDestination( auth.getAssertionConsumerServiceURL() ); 
     58      rsp.setID("some_unique_id_value_here"); 
     59      rsp.setInResponseTo( auth.getID() ); 
     60      rsp.setVersion(org.opensaml.common.SAMLVersion.VERSION_20); 
     61       
     62      IssuerBuilder ib = (IssuerBuilder) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME); 
     63      // Build the Issuer object 
     64      Issuer isr = ib.buildObject(); 
     65      isr.setValue("AcmeIdp"); 
     66      rsp.setIssuer(isr); 
     67       
     68      DateTime dt = new DateTime(); 
     69      rsp.setIssueInstant(dt); 
     70       
     71      // Now we must build our representation to put into the html form to be submitted to the idp 
     72      HTTPPostEncoder encoder = new HTTPPostEncoder(); 
     73      encoder.setSAMLMessage(rsp); 
     74       
     75      encoder.setRelayState( (String) session.getAttribute(_relaystate) ); 
     76      encoder.setResponse(response); 
     77      encoder.setActionURL( auth.getAssertionConsumerServiceURL() ); 
     78       
     79      encoder.encode(); 
     80      return; 
     81    } 
    2482%>     
    2583<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
  • AcmeIdp/trunk/web/recv-authnrequest.jsp

    r82 r137  
    3232  relayState = decode.getRelayState(); 
    3333   
     34  // Save the relay state information in our session 
     35  session.setAttribute(_relaystate, relayState); 
     36   
    3437  // Use the OpenSAML Configuration singleton to get a builder factory object 
    3538  XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); 
     
    4043 
    4144  auth = (AuthnRequestImpl) decode.getSAMLMessage(); 
     45  // Now save our AuthnRequest object 
     46  session.setAttribute(_authnrequest, auth); 
    4247   
    4348  Marshaller marshaller = org.opensaml.Configuration.getMarshallerFactory().getMarshaller(auth); 
     
    5257  messageXML = messageXML.replace("<", "&lt;"); 
    5358  messageXML = messageXML.replace(">", "&gt;"); 
     59   
     60  ResponseBuilder rspBldr = (ResponseBuilder) builderFactory.getBuilder(Response.DEFAULT_ELEMENT_NAME); 
     61  Response rsp = rspBldr.buildObject(); 
    5462 
    5563%>     
     
    7078    <table> 
    7179      <tr><td><% out.println( messageXML );%></td></tr> 
    72  
    7380    </table> 
     81     
     82    <h1>ACME Idp Login Page</h1> 
     83     
     84    <form name="login" method="POST" action="login.jsp"> 
     85    <table class="section"> 
     86      <tr><td>Idp Login ID:</td><td><input type="text" name="idploginid" id="idploginid" size="30"></td></tr> 
     87      <tr><td>Idp Password:</td><td><input type="text" name="password" id="password" size="30"></td></tr> 
     88      <tr><td colspan="2"><input type="submit" name="submit" value="Login"></td></tr> 
     89    </table> 
     90    </form> 
    7491     
    7592    </body>