Fix class cast exception
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 23 Sep 2008 03:24:50 +0000 (03:24 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 23 Sep 2008 03:24:50 +0000 (03:24 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/branches/REL_2@2768 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/main/java/edu/internet2/middleware/shibboleth/idp/profile/saml2/AbstractSAML2ProfileHandler.java

index 14c4328..17530e8 100644 (file)
@@ -880,7 +880,7 @@ public abstract class AbstractSAML2ProfileHandler extends AbstractSAMLProfileHan
      */
     protected void writeAuditLogEntry(BaseSAMLProfileRequestContext context) {
         SAML2AuditLogEntry auditLogEntry = new SAML2AuditLogEntry();
-        auditLogEntry.setSAMLResponse((Response) context.getOutboundSAMLMessage());
+        auditLogEntry.setSAMLResponse((StatusResponseType) context.getOutboundSAMLMessage());
         auditLogEntry.setMessageProfile(getProfileId());
         auditLogEntry.setPrincipalAuthenticationMethod(context.getPrincipalAuthenticationMethod());
         auditLogEntry.setPrincipalName(context.getPrincipalName());
@@ -901,14 +901,14 @@ public abstract class AbstractSAML2ProfileHandler extends AbstractSAMLProfileHan
     protected class SAML2AuditLogEntry extends AuditLogEntry {
 
         /** The response to the SAML request. */
-        private Response samlResponse;
+        private StatusResponseType samlResponse;
 
         /**
          * Gets the response to the SAML request.
          * 
          * @return the response to the SAML request
          */
-        public Response getSAMLResponse() {
+        public StatusResponseType getSAMLResponse() {
             return samlResponse;
         }
 
@@ -917,17 +917,19 @@ public abstract class AbstractSAML2ProfileHandler extends AbstractSAMLProfileHan
          * 
          * @param response the response to the SAML request
          */
-        public void setSAMLResponse(Response response) {
+        public void setSAMLResponse(StatusResponseType response) {
             samlResponse = response;
         }
 
         /** {@inheritDoc} */
         public String toString() {
             StringBuilder entryString = new StringBuilder(super.toString());
-            
+
             NameID nameIdentifier = null;
             StringBuilder assertionIds = new StringBuilder();
-            List<Assertion> assertions = samlResponse.getAssertions();
+
+            if(samlResponse instanceof Response){
+            List<Assertion> assertions = ((Response)samlResponse).getAssertions();
             if(assertions != null && !assertions.isEmpty()){
                 for(Assertion assertion : assertions){
                     assertionIds.append(assertion.getID());
@@ -940,6 +942,7 @@ public abstract class AbstractSAML2ProfileHandler extends AbstractSAMLProfileHan
                     }
                 }
             }
+            }
             
             if(nameIdentifier != null){
                 entryString.append(nameIdentifier.getValue());