Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • action what the Ds has to do. Possible contents are:
    • lookup - refresh the screen.
    • search - perform a search on the contents parameter "string"
    • selection - redirect to the IdP with the uri origin
  • cache preserve any selection in the _saml_idp cookie. A value of "session" makes the cookie last for the browser session, "perm" gives it the lifetime asd as described in DSUserInterface.

Accessing the metadata extension for login and discovery

...

As a side-effect of updated the supporting libraries in the 1V1.1.3 release the DS can access the the information described in <mdui:UIInfo> extensions, as described here

...

Warning
titleWarning

This information will change in later versions. Expect We expect to have to make substantial alterations to support these changes.
These code segments are provided as is. Remember this is not a supported interface.

Importing the

...

required libraries

The code segment below require requires that certain packages are declared:

Code Block
xml
xml
<%@ page language="java" import="java.util.*, edu.internet2.middleware.shibboleth.wayf.*, java.lang.*, org.opensaml.xml.*, org.opensaml.saml2.common.*, org.opensaml.saml2.metadata.*, org.opensaml.samlext.saml2mdui.*, javax.servlet.http.*, java.net.*"%>
Locating the MDUI information for the SP

...

In non-error cases, an object representing the SP is available via the attribute named “providerObject”. The code section below shows how to access the SP, and navigate to find the <mdui:DisplayName> and <mdui:Logo>. Note that no filtering for size or language is being applied.

Finally, if not no name is located, the entity name is inspected to try to generate a “user friendly” display name for the SP.

Code Block
java
java
<%
  String spName = null;
  String spLogo = null;

  EntityDescriptor sp = (EntityDescriptor) request.getAttribute("providerObject");
  if (null != sp) {
    List<RoleDescriptor> roles = sp.getRoleDescriptors();
    for (RoleDescriptor r:roles) {
      Extensions ex = r.getExtensions();
      if (null == ex) { 
      	  continue;
      }
      List<XMLObject> splist = ex.getOrderedChildren();
      for (XMLObject o:splist) { 
        if (o instanceof UIInfo) { 
          UIInfo info=null;
          info = (UIInfo) o;
          if (info.getLogos() != null) {
            for (Logo logo : info.getLogos()) { 
              if (logo.getHeight() <= 16 && logo.getWidth() <= 16) continue;
              if (null == spLogo) spLogo = logo.getURL();
              break;
            }
            for (DisplayName dn : info.getDisplayNames()) { 
              if (null == spName) spName = dn.getName().getLocalString();
              break;
            }
          }
        }
      }
    }
    if (spName == null) {
      try {
        URI uriId = new URI(sp.getEntityID());
        String scheme = uriId.getScheme();
  
        if ("http".equals(scheme) || "https".equals(scheme)) {
          spName = uriId.getHost(); 
        } else {
          spName = sp.getEntityID();
        }
      } catch (URISyntaxException e) {
        // 
        // It wasn't an URI.  return full entityId.
        //
        spName = sp.getEntityID();
      }
    }
  } else {
 
    spName = "Unknown Service Provider";
  }
%> 
Locating all available Logos for the IdPs

...

As described in the prototype wayf.jsp file the sites are available via the request attribute terms “sites”. The code segment below sets up a JavaScript associative array of icons (logos of size 16x16) and logos selected for best fit (according to the same rules that the Shibboleth EDS uses). Again language is ignored but could be trivially added.

Code Block
xml
xml
<%
   double bestRatio = Math.log(80.0/60.0);
   sites = (TreeSet<IdPSite>) request.getAttribute("sites");
%>
<script  type="text/javascript">
var theIcons =[];
var theLogos=[];<%
  for (IdPSite site:sites) { 
     if (null == site.getExtensions()) { continue; }
     List<XMLObject> list = site.getExtensions().getOrderedChildren();
     UIInfo info=null;
     for (XMLObject o:list) { 
        if (o instanceof UIInfo) { 
          info = (UIInfo) o;
          break;
        }
     }
     if (info == null) { continue;}
     if (null == info.getLogos() || 0 == info.getLogos().size()) { continue;}
     String logoUrl = null;
     String iconUrl = null;
     double curRatio = 0;
     for (Logo logo : info.getLogos()) { 
        if (logo.getHeight() <= 16 && logo.getWidth() <= 16) {
	   iconUrl = logo.getURL();
           continue;
        }
        if (logoUrl == null) {
	   logoUrl = logo.getURL();
           curRatio = Math.log(logo.getWidth()/logo.getHeight());
           continue;
        }
        double ratio = Math.log(logo.getWidth()/logo.getHeight());
        double him = Math.abs(bestRatio - curRatio);
        double me = Math.abs(bestRatio - curRatio);
        if (him > me) {
	   logoUrl = logo.getURL();
           curRatio = ratio;
        }
     }
     if (logoUrl != null) {%> theLogos['<%=site.getName()%>']='<%=logoUrl%>';
<%}
     if (iconUrl != null) {%> theIcons['<%=site.getName()%>']='<%=iconUrl%>';
<%}
   }%>

</script>

...

This should be a relatively simple extension of the code samples above. Interested parties are encouraged to add to this code page.