package edu.internet2.middleware.shibboleth.serviceprovider;
import java.io.IOException;
+import java.util.Iterator;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
+import org.opensaml.SAMLAudienceRestrictionCondition;
import org.opensaml.SAMLBrowserProfile;
+import org.opensaml.SAMLCondition;
import org.opensaml.SAMLException;
import org.opensaml.SAMLResponse;
import org.opensaml.SAMLBrowserProfile.BrowserProfileResponse;
-import org.w3c.dom.Element;
-
import x0.maceShibbolethTargetConfig1.SessionsDocument.Sessions;
-import edu.internet2.middleware.shibboleth.common.Credentials;
import edu.internet2.middleware.shibboleth.common.ShibBrowserProfile;
import edu.internet2.middleware.shibboleth.metadata.MetadataException;
import edu.internet2.middleware.shibboleth.resource.AuthenticationFilter;
private static ServiceProviderContext context = ServiceProviderContext.getInstance();
- private Element configuration = null;
- private Credentials credentials = null;
-
public static final String SESSIONPARM =
"ShibbolethSessionId";
String sessionid=null;
StringBuffer pproviderId = // Get back IdP Entity name from SAML
new StringBuffer();
- String[] audiences = new String[1];
- audiences[0]=providerId;
ShibBrowserProfile profile = new ShibBrowserProfile(applicationId);
BrowserProfileResponse samldata = profile.receive(
1
);
- // TODO: Audience/condition checking is now the profile caller's job.
+ Iterator conditions = samldata.assertion.getConditions();
+ while (conditions.hasNext()) {
+ SAMLCondition cond =
+ (SAMLCondition)conditions.next();
+
+ if (cond instanceof SAMLAudienceRestrictionCondition) {
+ SAMLAudienceRestrictionCondition audienceCondition =
+ (SAMLAudienceRestrictionCondition) cond;
+ Iterator audiences = audienceCondition.getAudiences();
+ if (audiences==null)
+ continue; // probably invalid
+ boolean matched = false;
+ while (audiences.hasNext()) {
+ String audienceString = (String) audiences.next();
+ if (audienceString.equals(providerId)) {
+ matched=true;
+ break;
+ }
+ }
+ if (!matched) {
+ throw new SAMLException("Assertion restricted to other audiences.");
+ }
+ }
+ }
// The Authentication Assertion gets placed in a newly created
// Session object. Later, someone will get an Attribute Assertion