User:Emetsger:ExampleAspects:SSOInformation

From DSpace Wiki

Jump to: navigation, search

[edit] Notes

  • JhuNavigation is a bad name
  • If I had to do this again I probably wouldn't pull the SSO value out of the database, instead I'd pull it from HTTP.
  • The 'jhu_authentication' metadata element is not used by the business layer; SSO authentication/authorization has already occurred. The element is there purely to allow stylers to add hints in the UI that the user has authenticated with SSO.
  • In retrospect I should have put this in its own aspect instead of modifying the EPerson aspect.

[edit] aspects/EPerson/sitemap.xmap

 ...
 <map:transformers>
   ...
   <map:transformer name="IsSsoLogin" src="edu.jhu.library.dspace.app.xmlui.eperson.JhuNavigation"/>
   ...
 </map:transformers>          
 ...
 <map:pipelines>
   <map:pipeline>
     ...
     <map:transform type="Navigation"/>
                   
     <map:transform type="IsSsoLogin"/>
     ...
        

[edit] aspects/EPerson/src/edu/jhu/library/dspace/app/xmlui/eperson/JhuNavigation.java

 package edu.jhu.library.dspace.app.xmlui.eperson;
 
 import edu.jhu.library.dspace.eperson.JhuEpersonDbField;
 import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
 import org.dspace.app.xmlui.utils.UIException;
 import org.dspace.app.xmlui.wing.WingException;
 import org.dspace.app.xmlui.wing.element.UserMeta;
 import org.dspace.authorize.AuthorizeException;
 import org.dspace.eperson.EPerson;
 import org.xml.sax.SAXException;
 
 import java.io.IOException;
 import java.sql.SQLException;
 
 /**
  * Emits JHU-specific Single Sign On information into the DRI. 
  */
 public class JhuNavigation extends AbstractDSpaceTransformer
 {
 
     public void addUserMeta( UserMeta userMeta ) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException
     {        
         EPerson ePerson = context.getCurrentUser();
         if ( ePerson != null )
         {
             if ( "true".equalsIgnoreCase( ePerson.getMetadata( JhuEpersonDbField.SSO_LOGIN ) ) )
             {
                 userMeta
                     .addMetadata( JhuDri.DRI_AUTHN_ELEMENT, JhuDri.AUTHN_QUALIFIER_SSO )
                     .addContent( JhuDri.AUTHN_SSO_ENABLED );
             }
         }
     }
 
 }
Personal tools