Changeset 78


Ignore:
Timestamp:
12/04/12 15:37:49 (7 years ago)
Author:
philsmart
Message:

changed audit date format, added email to subscribed users, added all SAML protocol support to determine IDPs

Location:
urlgenerator/trunk/src/main
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • urlgenerator/trunk/src/main/java/uk/ac/cardiff/wayf/urlgenerator/metadata/AbstractSamlMetadataHandler.java

    r73 r78  
    6767     * Method that returns true if the {@link EntityDescriptor} <code>entity</code> represents an Identity Provider, 
    6868     * false otherwise. Identity providers are identified by those that have an 
    69      * {urn:oasis:names:tc:SAML:2.0:metadata}IDPSSODescriptor element. 
     69     * {urn:oasis:names:tc:SAML:2.0/1.1/1.0:metadata}IDPSSODescriptor element. 
    7070     *  
    7171     * @param entity the {@link EntityDescriptor} to check 
     
    7777            return false; 
    7878        } 
    79  
     79        log.trace("Checking is identity provider for [{}]", entity.getEntityID()); 
    8080        for (String ssoProtocol : WugenSamlConstants.SUPPORTED_SAML_SSO_PROTOCOLS) { 
    8181            if (entity.getIDPSSODescriptor(ssoProtocol) != null) { 
    8282                log.trace("has supported SAML IDPSSODescriptor {}, where constant is {}", 
    83                         entity.getSPSSODescriptor(ssoProtocol), ssoProtocol); 
     83                        entity.getIDPSSODescriptor(ssoProtocol), ssoProtocol); 
    8484                return true; 
    8585            } 
  • urlgenerator/trunk/src/main/java/uk/ac/cardiff/wugen/generator/engine/WayflessGenerator.java

    r67 r78  
    33 
    44import java.net.URL; 
    5 import java.util.Date; 
    65import java.util.Map; 
    76import java.util.TreeSet; 
    87 
     8import org.joda.time.DateTime; 
     9import org.joda.time.format.DateTimeFormatter; 
     10import org.joda.time.format.ISODateTimeFormat; 
    911import org.slf4j.Logger; 
    1012import org.slf4j.LoggerFactory; 
     
    7577                log.debug("Generated wayfless URL [{}]", generatedUrl.getGeneratedWayflessUrl().toString()); 
    7678                log.debug("Wayfless URL Quality [{}]", generatedUrl.getUrlReliability()); 
    77                 logAudit.info( 
    78                         "{},{},{},{},{},{}", 
    79                         new Object[] {new Date(), generatedUrl.getGeneratedWayflessUrl().toString(), 
    80                                 generatorContext.getSelectedIdPEntity(), generatorContext.getSelectedSpEntity(), 
    81                                 generatorContext.getSelectedTarget(), generatedUrl.getUrlReliability()}); 
     79                log(generatedUrl, generatorContext); 
    8280                return generatedUrl; 
    8381            } catch (GeneratorException e) { 
     
    9290    } 
    9391 
     92    private void log(GeneratedUrl generatedUrl, GeneratorContext generatorContext) { 
     93        DateTime dt = new DateTime(); 
     94        DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); 
     95        String str = fmt.print(dt); 
     96        logAudit.info( 
     97                "{},{},{},{},{},{}", 
     98                new Object[] {str, generatedUrl.getGeneratedWayflessUrl().toString(), 
     99                        generatorContext.getSelectedIdPEntity(), generatorContext.getSelectedSpEntity(), 
     100                        generatorContext.getSelectedTarget(), generatedUrl.getUrlReliability()}); 
     101    } 
     102 
     103    @Override 
    94104    public void afterPropertiesSet() throws Exception { 
    95105        log.info("WayflessGenerator has been asked to register the set of generators automatically from the application context"); 
     
    116126    } 
    117127 
     128    @Override 
    118129    public void setApplicationContext(ApplicationContext context) throws BeansException { 
    119130        applicationContext = context; 
  • urlgenerator/trunk/src/main/java/uk/ac/cardiff/wugen/generator/service/EmailService.java

    r29 r78  
    22 *  
    33 */ 
     4 
    45package uk.ac.cardiff.wugen.generator.service; 
    56 
    67import uk.ac.cardiff.wugen.generator.engine.mail.TemplateEmailContext; 
    78import uk.ac.cardiff.wugen.generator.model.GeneratedUrl; 
    8 import uk.ac.cardiff.wugen.generator.model.GeneratorContext; 
    99 
    1010/** 
    1111 * @author philsmart 
    12  * 
     12 *  
    1313 */ 
    1414public interface EmailService { 
    15      
     15 
    1616    public void emailWayflessUrl(TemplateEmailContext emailContext, GeneratedUrl generatedUrl); 
    1717 
    18  
    1918} 
  • urlgenerator/trunk/src/main/java/uk/ac/cardiff/wugen/generator/service/impl/EmailServiceImpl.java

    r38 r78  
    3131    private EmailHandler emailHandler; 
    3232 
     33    @Override 
     34    @SuppressWarnings({"rawtypes", "unchecked"}) 
    3335    public void emailWayflessUrl(TemplateEmailContext emailContext, GeneratedUrl generatedUrl) { 
    3436        log.info("Emailing Generated WAYFless URL [{}] to [{}]", generatedUrl.getGeneratedWayflessUrl() 
  • urlgenerator/trunk/src/main/java/uk/ac/cardiff/wugen/generator/service/impl/SubscriptionServiceImpl.java

    r39 r78  
    66 
    77import java.util.ArrayList; 
     8import java.util.HashMap; 
    89import java.util.List; 
     10import java.util.Map; 
    911 
    1012import javax.faces.model.SelectItem; 
     
    1315import org.slf4j.LoggerFactory; 
    1416 
     17import uk.ac.cardiff.wugen.generator.engine.mail.EmailHandler; 
    1518import uk.ac.cardiff.wugen.generator.engine.mail.EmailInterfaceSelector; 
     19import uk.ac.cardiff.wugen.generator.engine.mail.Emailer; 
    1620import uk.ac.cardiff.wugen.generator.engine.mail.SimpleEmailContext; 
    1721import uk.ac.cardiff.wugen.generator.engine.mail.SubscribedUsersImprovedUrlBackgroundTaskHandler; 
     22import uk.ac.cardiff.wugen.generator.engine.mail.TemplateEmailContext; 
    1823import uk.ac.cardiff.wugen.generator.model.AdminEmailSelectorBean; 
    1924import uk.ac.cardiff.wugen.generator.model.GeneratedUrl; 
     
    4550    private SubscribedUserHashToken hashTokenService; 
    4651 
     52    /** 
     53     * The {@link Emailer} used to send welcome emails. 
     54     */ 
     55    private EmailHandler emailHandler; 
     56 
     57    @Override 
    4758    public EmailInterfaceSelector initialiseEmailSelector() { 
    4859        EmailInterfaceSelector emailSelector = new EmailInterfaceSelector(); 
     
    5162    } 
    5263 
     64    @Override 
    5365    public void subscribeUser(GeneratorContext generatorContext, SimpleEmailContext emailContext, 
    5466            GeneratedUrl generatedUrl) { 
     
    6981            } else { 
    7082                MessageGenerator.addInfo("Subscription succeeded"); 
     83                sendSubscribedUserWelcomeMessage(user, generatedUrl); 
    7184            } 
    7285 
     
    7790    } 
    7891 
     92    @SuppressWarnings({"unchecked", "rawtypes"}) 
     93    private void sendSubscribedUserWelcomeMessage(SubscribedUser user, GeneratedUrl generatedUrl) { 
     94        log.info("Sending welcome message to newly subscribed user [{}]", user.getEmailAddress()); 
     95        TemplateEmailContext emailContext = new TemplateEmailContext(); 
     96        Map model = new HashMap(); 
     97        model.put("generatedUrl", generatedUrl.getGeneratedWayflessUrl()); 
     98        model.put("emailToken", user.getToken()); 
     99        model.put("serviceProvider", user.getServiceProviderEntityId()); 
     100        model.put("identityProvider", user.getIdentityProviderEntityId()); 
     101        model.put("urlReliability", generatedUrl.getUrlReliability()); 
     102        emailContext.setModel(model); 
     103        emailContext.setEmailAddress(user.getEmailAddress()); 
     104        emailHandler.sendEmail(emailContext, "wayflessUrlSubscribedUserWelcomeMessageContext"); 
     105    } 
     106 
     107    @Override 
    79108    public void setSubscriptionsFor(AdminEmailSelectorBean emailBean) { 
    80109        List<SubscribedUser> subscriptions = wugenSubscribedUserDao.getSubscriptionsFor(emailBean.getSelectedEmail()); 
     
    93122    } 
    94123 
     124    @Override 
    95125    public void unsubscribe(UnsubscribeFormBean unsubscribeFormBean) { 
    96126        log.info("Unsubscribing email address {} with token {}", unsubscribeFormBean.getEmailAddress(), 
     
    109139    } 
    110140 
     141    @Override 
    111142    public void removeCurrentlySelectedSubscription(AdminEmailSelectorBean emailBean) { 
    112143        wugenSubscribedUserDao.delete(emailBean.getSelectedSubscribedEmail()); 
    113144    } 
    114145 
     146    @Override 
    115147    public void checkImprovedUrl(GeneratedUrl generatedUrl) { 
    116148        log.info("Running check on better WAYFless URLs with [{}]", generatedUrl); 
     
    160192    } 
    161193 
     194    /** 
     195     * @return Returns the emailHandler. 
     196     */ 
     197    public EmailHandler getEmailHandler() { 
     198        return emailHandler; 
     199    } 
     200 
     201    /** 
     202     * @param emailHandler The emailHandler to set. 
     203     */ 
     204    public void setEmailHandler(EmailHandler emailHandler) { 
     205        this.emailHandler = emailHandler; 
     206    } 
     207 
    162208} 
  • urlgenerator/trunk/src/main/resources/email-templates/wayfless-url-email-template.vm

    r39 r78  
    33<h3>Dear Sir/Madam,</h3> 
    44<div> 
    5 Below is the WAYFless URL request from the Wugen web application. 
     5Below is the WAYFless URL that you just requested from the UK federation WAYFless URL generator web application. 
    66</div> 
    77<br/> 
    88<div> 
    9    <a href="${generatedUrl.generatedWayflessUrl}">${generatedUrl.generatedWayflessUrl}</a>. 
     9  <a href="${generatedUrl.generatedWayflessUrl}">${generatedUrl.generatedWayflessUrl}</a>. 
    1010</div> 
    1111 
    12 <p> 
    13 Thank you for using our service <br/> 
    14 The Wugen Team 
    15 </p> 
     12<p>If you have any questions about this service, please email service@jisc-collections.ac.uk</p>. 
    1613</body> 
    1714 
  • urlgenerator/trunk/src/main/resources/email-templates/wayfless-url-notification-email-template.vm

    r39 r78  
    22<body> 
    33<h3>Dear Sir/Madam,</h3> 
     4<p> 
     5A more reliable WAYFless URL has been generated for the service provider ${serviceProvider} that you have subscribed to. 
     6</p> 
     7<br/> 
     8<p> The new WAYFless URL for your identity provider ${identityProvider} is: 
    49<div> 
    5 A more reliable WAYFless URL has been generated for the service provider ${serviceProvider}. Your previously generated WAYFless URL has a reliability rating of ${previousUrlQuality}, 
    6 the new WAYFless URL has a reliability rating of ${urlReliability}. URL reliability is rated as follows: 
    7 <ul> 
    8 <ul> 
    9 <li>1 - The worst kind of WAYFless URL. IdP-side, Shib 1 bindings.</li> 
    10 <li>2 - A little bit better, but still brittle. IdP-side, Shib 2 Unsolicited bindings.</li> 
    11 <li>3-8 - Not yet defined, but included for future flexibility.</li> 
    12  <li>9 - Pretty reliable WAYFless URL - SP-side using discovery bindings from metadata.</li> 
    13 <li>10 - Ultimate reliability WAYFless URL - location of Session Initiator manually provided by service and configured by admins.</li> 
    14 </ul> 
    15 </ul> 
     10  <a href="${generatedUrl.generatedWayflessUrl}">${generatedUrl.generatedWayflessUrl}</a>. 
    1611</div> 
    17 <br/> 
    18 <p> The new WAYFless URL for your identity provider ${identityProvider}  is: 
    19 <div> 
    20    <a href="${generatedUrl.generatedWayflessUrl}">${generatedUrl.generatedWayflessUrl}</a>. 
    21 </div> 
     12</p> 
     13 
     14<p>If you have any questions about this service, please email service@jisc-collections.ac.uk.</p> 
    2215 
    2316<p> 
    24 Thank you for using our service <br/> 
    25 The Wugen Team 
     17To unsubscribe from this particular WAYFless URL reminder, visit <a href="http://wugen.ukfederation.org.uk/urlgenerator/wugen/unsubscribe">this page</a> with this token ${emailToken}. 
    2618</p> 
    27  
    28 <p> 
    29 To unsubscribe to this email, remember this magic string ${emailToken} and oralate it back to us. 
    3019</body> 
    3120 
  • urlgenerator/trunk/src/main/resources/messages_en.properties

    r68 r78  
    1717navigation.cancel=cancel 
    1818navigation.next=next 
     19error.errorMsgTitle=Error. 
     20error.errorMsg=A WAYFless URL is not available at this time.  
  • urlgenerator/trunk/src/main/webapp/WEB-INF/config/mail.xml

    r33 r78  
    2525           <property name="emailerPropertiesIdentifier" value="wayflessUrlEmailContext"/> 
    2626           <property name="title" value="WAYFless URL Generation"/> 
    27            <property name="fromEmailAddress" value="wugen@cf.ac.uk"/> 
     27           <property name="fromEmailAddress" value="noreply@wugen.ukfederation.org.uk"/> 
    2828           <property name="templateLocation" value="classpath:email-templates/wayfless-url-email-template.vm"/> 
    2929        </bean> 
     30     
     31    <bean id="wayflessUrlSubscribedUserWelcomeMessageContext" class="uk.ac.cardiff.wugen.generator.engine.mail.EmailerProperties"> 
     32       <property name="emailerPropertiesIdentifier" value="wayflessUrlSubscribedUserWelcomeMessageContext"/> 
     33       <property name="title" value="WAYFless URL Subscription Notification"/> 
     34       <property name="fromEmailAddress" value="noreply@wugen.ukfederation.org.uk"/> 
     35       <property name="templateLocation" value="classpath:email-templates/wayfless-url-subscribed-user-welcome-email-template.vm"/> 
     36    </bean> 
    3037         
    3138         
     
    3340       <property name="emailerPropertiesIdentifier" value="wayflessUrlNotificationEmailContext"/> 
    3441       <property name="title" value="WAYFless URL Notification"/> 
    35        <property name="fromEmailAddress" value="wugen@cf.ac.uk"/> 
     42       <property name="fromEmailAddress" value="noreply@wugen.ukfederation.org.uk"/> 
    3643       <property name="templateLocation" value="classpath:email-templates/wayfless-url-notification-email-template.vm"/> 
    3744    </bean> 
  • urlgenerator/trunk/src/main/webapp/WEB-INF/config/wugen-core.xml

    r68 r78  
    6565        <property name="improvedUrlEngine"> 
    6666            <ref bean="subscribedUserImprovedUrlEngine" /> 
     67        </property> 
     68        <property name="emailHandler"> 
     69            <ref bean="emailHandler" /> 
    6770        </property> 
    6871        </bean> 
  • urlgenerator/trunk/src/main/webapp/WEB-INF/flows/generate/error.xhtml

    r24 r78  
    2727 
    2828        <ui:define name="content"> 
    29  
     29        <a4j:loadBundle basename="messages" var="msg"/> 
    3030                <rich:panel bodyClass="rich-laguna-panel-no-header"> 
    3131                        <center> 
    32                                 <font size="3" face="verdana"> <b>Error.</b> There was an 
    33                                         error generating your wayfless URL. Who is to blame, you? me? or 
    34                                         Jon Quinn? </font> 
     32                                <font size="3" face="verdana"> <b>#{msg['error.errorMsgTitle']}</b> #{msg['error.errorMsg']}</font> 
    3533 
    3634                                <rich:spacer height="20xpx" /> 
  • urlgenerator/trunk/src/main/webapp/WEB-INF/flows/generate/generate-subflow.xml

    r38 r78  
    8484                        <evaluate 
    8585                expression="subscriptionService.subscribeUser(flowScope.selectedInformation,subscriptionEmailContext,viewScope.wayflessUrl)" /> 
     86              
    8687                </transition> 
    8788 
  • urlgenerator/trunk/src/main/webapp/login.jsp

    r73 r78  
    152152                                                <br /> 
    153153                                        </center> 
     154                                        <table> 
     155                                           <tr> 
     156                                               <td>For support, please contact <a href="mailto:service@jisc-collections.ac.uk">service@jisc-collections.ac.uk</a></td> 
     157                                           </tr> 
     158                                        </table> 
    154159                                </div> 
    155160                        </div> 
  • urlgenerator/trunk/src/main/webapp/template/css/common.css

    r36 r78  
    6262#nav li a:hover {  color:#CCF; } 
    6363 
    64 #content { width:95%; padding:30px 30px 30px; min-height:543px; text-align:left;  } 
     64#content { width:95%; padding:30px 30px 30px; text-align:left;  } 
    6565* html #content, * html #content #col_1 { height:543px; } 
    6666 
    67 #content #col_1 { width:100%; float:left; min-height:543px; background:url(../images/bg_left.gif) no-repeat 100% 50%; } 
     67#content #col_1 { width:100%; float:left; background:url(../images/bg_left.gif) no-repeat 100% 50%; } 
    6868#content #col_1 h2 { color:#999999; font-size:14px; font-weight:normal; } 
    6969#subnav, #subnav ul { margin:0; padding:0; list-style:none; } 
  • urlgenerator/trunk/src/main/webapp/template/full.xhtml

    r73 r78  
    8282 
    8383                <li><a href="urlgenerator/j_spring_security_logout">Logout</a></li>  
     84                 
    8485            </ul> 
    8586        </a4j:form> 
     
    9192                        </div> 
    9293                </div> 
     94                 
     95                <div id="footer"> 
     96    For support, please contact <a href="mailto:service@jisc-collections.ac.uk">service@jisc-collections.ac.uk</a> 
     97</div> 
    9398 
    9499 
Note: See TracChangeset for help on using the changeset viewer.