Changeset 139

Show
Ignore:
Timestamp:
04/27/07 15:59:12 (2 years ago)
Author:
paulhethmon
Message:

--

Files:

Legend:

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

    r137 r139  
    44<%@include file="include.jsp"%> 
    55 
     6<%@ page import="java.io.StringWriter" %> 
    67<%@ page import="org.joda.time.DateTime" %> 
    78 
     
    6970      rsp.setIssueInstant(dt); 
    7071       
     72      // Add an Assertion of this authenticated user 
     73      AssertionBuilder ab = (AssertionBuilder) builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME); 
     74      Assertion as = ab.buildObject(); 
     75      // Build the AuthnStatement itself 
     76      AuthnStatementBuilder asb = (AuthnStatementBuilder) builderFactory.getBuilder(AuthnStatement.DEFAULT_ELEMENT_NAME); 
     77      AuthnStatement ans = asb.buildObject(); 
     78      ans.set 
     79       
     80      // Now add a subject to the response 
     81      SubjectBuilder sb = (SubjectBuilder) builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME); 
     82      Subject sub = sb.buildObject(); 
     83      NameIDBuilder nidb = (NameIDBuilder) builderFactory.getBuilder(NameID.DEFAULT_ELEMENT_NAME); 
     84      NameID nid = nidb.buildObject(); 
     85      nid.setValue(idpLoginId); 
     86      sub.setNameID(nid); 
     87 
     88       
    7189      // 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); 
     90      Marshaller marshaller = org.opensaml.Configuration.getMarshallerFactory().getMarshaller(rsp); 
     91      Element authDOM = marshaller.marshall(rsp); 
     92      StringWriter rspWrt = new StringWriter(); 
     93      XMLHelper.writeNode(authDOM, rspWrt); 
     94      String messageXML = rspWrt.toString(); 
     95 
     96      String samlResponse = new String(Base64.encodeBytes(messageXML.getBytes(), Base64.DONT_BREAK_LINES)); 
    7497       
    75       encoder.setRelayState( (String) session.getAttribute(_relaystate) ); 
    76       encoder.setResponse(response); 
    77       encoder.setActionURL( auth.getAssertionConsumerServiceURL() ); 
     98      String actionURL = auth.getAssertionConsumerServiceURL(); 
    7899       
    79       encoder.encode(); 
     100      messageXML = messageXML.replace("<", "&lt;"); 
     101      messageXML = messageXML.replace(">", "&gt;"); 
     102%> 
     103<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
     104   "http://www.w3.org/TR/html4/loose.dtd"> 
     105<html> 
     106    <head> 
     107        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     108        <title>ACME Idp Login</title> 
     109        <link rel="stylesheet" type="text/css" href="main.css"> 
     110    </head> 
     111    <body> 
     112    <p>Please press the continue button to proceed.</p> 
     113    <form action="<% out.print(actionURL); %>" method="post"> 
     114        <input type="hidden" name="RelayState" value="<% out.print(relayState); %>"> 
     115        <input type="hidden" name="SAMLResponse" value="<% out.print(samlResponse); %>"> 
     116        <input type="submit" value="Continue"> 
     117    </form> 
     118     
     119    <p> 
     120    <%out.print(messageXML);%> 
     121    </p> 
     122    </body> 
     123</html> 
     124<% 
    80125      return; 
    81126    } 
  • AcmeIdp/trunk/web/recv-authnrequest.jsp

    r137 r139  
    44<%@include file="include.jsp"%> 
    55 
     6<%@ page import="java.io.StringWriter" %> 
    67<%@ page import="org.joda.time.DateTime" %> 
    78 
     
    4849  Marshaller marshaller = org.opensaml.Configuration.getMarshallerFactory().getMarshaller(auth); 
    4950  Element authDOM = marshaller.marshall(auth); 
    50   String messageXML = XMLHelper.nodeToString(authDOM); 
     51  StringWriter rspWrt = new StringWriter(); 
     52  XMLHelper.writeNode(authDOM, rspWrt); 
     53  String messageXML = rspWrt.toString(); 
    5154/*   
    5255  UnmarshallerFactory unmarshallerFactory = org.opensaml.Configuration.getUnmarshallerFactory();