From c9248b1f81c2fabb5c13bc6cd83caa7c6464f421 Mon Sep 17 00:00:00 2001 From: j2blake Date: Wed, 9 Oct 2013 16:38:14 -0400 Subject: [PATCH] VIVO-333 External-auth login button should be language-sensitive. Don't specify the text in the runtime.properties. Instead, get it from all.properties. Show the button if externalAuth.netIdHeaderName is specified. --- doc/install.html | 28 +- webapp/config/example.runtime.properties | 370 +++++++++--------- .../languages/example/i18n/all_es.properties | 1 + .../vitro/webapp/web/widgets/LoginWidget.java | 14 +- webapp/web/i18n/all.properties | 1 + .../freemarker/widgets/widget-login.ftl | 2 +- 6 files changed, 207 insertions(+), 209 deletions(-) diff --git a/doc/install.html b/doc/install.html index 6b57019bd..8a1302f3e 100644 --- a/doc/install.html +++ b/doc/install.html @@ -397,7 +397,7 @@ External authentication: If you want to use an external authentication system like Shibboleth or CUWebAuth, you will need to - set two additional properties in this file. See the section below + set an additional property in this file. See the section below entitled Using an External Authentication System with Vitro.

@@ -647,21 +647,16 @@ @@ -1081,14 +1076,19 @@ the Vitro login form. You need to tell Vitro what text should appear in that button.

- Put a line like this in the runtime.properties file: - externalAuth.buttonText = [the text for your login button] For example: -

-
externalAuth.buttonText = Log in using BearCat Shibboleth
-

+ In your theme, add a line to the all.properties file, + like this one: +

external_login_text = [the text for your login button]
+ For example: +
external_login_text = Log in using BearCat Shibboleth
The Vitro login form will display a button labelled "Log in using BearCat Shibboleth".

+

+ If your site supports additional languages, add lines to the corresponding files. + For example, all_es.properties might contain this line: +

external_login_text = Entrar usando Shibboleth GatoOso
+

  • Associating a User with a profile page.
    diff --git a/webapp/config/example.runtime.properties b/webapp/config/example.runtime.properties index c91188ae3..4fb6f9449 100644 --- a/webapp/config/example.runtime.properties +++ b/webapp/config/example.runtime.properties @@ -1,186 +1,184 @@ -# ----------------------------------------------------------------------------- -# -# Vitro runtime properties -# -# This file is provided as example.runtime.properties. -# -# Save a copy of this file as runtime.properties in your Vitro home directory, -# and edit the properties as needed for your installation. -# -# ----------------------------------------------------------------------------- - -# -# This namespace will be used when generating URIs for objects created in the -# editor. In order to serve linked data, the default namespace must be composed -# as follows (optional elements in parentheses): -# -# scheme + server_name (+ port) (+ servlet_context) + "/individual/" -# -# For example, Cornell's default namespace is: -# -# http://vivo.cornell.edu/individual/ -# -Vitro.defaultNamespace = http://vivo.mydomain.edu/individual/ - -# -# URL of Solr context used in local Vitro search. This will usually consist of: -# scheme + server_name + port + vitro_webapp_name + "solr" -# In the standard installation, the Solr context will be on the same server as Vitro, -# and in the same Tomcat instance. The path will be the Vitro webapp.name (specified -# above) + "solr" -# Example: -# vitro.local.solr.url = http://localhost:8080/vitrosolr -vitro.local.solr.url = http://localhost:8080/vitrosolr - -# -# Email parameters which VIVO can use to send mail. If these are left empty, -# the "Contact Us" form will be disabled and users will not be notified of -# changes to their accounts. -# -email.smtpHost = smtp.my.domain.edu -email.replyTo = vivoAdmin@my.domain.edu - -# -# The basic parameters for a MySQL database connection. Change the end of the -# URL to reflect your database name (if it is not "vitro"). Change the username -# and password to match the authorized user you created in MySQL. -# -VitroConnection.DataSource.url = jdbc:mysql://localhost/vitro -VitroConnection.DataSource.username = vitroweb -VitroConnection.DataSource.password = vitrovitro - -# -# The maximum number of active connections in the database connection pool. -# Increase this value to support a greater number of concurrent page requests. -# -VitroConnection.DataSource.pool.maxActive = 40 - -# -# The maximum number of database connections that will be allowed -# to remain idle in the connection pool. Default is 25% -# of the maximum number of active connections. -# -VitroConnection.DataSource.pool.maxIdle = 10 - -# -# Parameters to change in order to use VIVO with a database other than -# MySQL. -# -VitroConnection.DataSource.dbtype = MySQL -VitroConnection.DataSource.driver = com.mysql.jdbc.Driver -VitroConnection.DataSource.validationQuery = SELECT 1 - -# -# Optional URI of a SPARQL endpoint from which VIVO should display data. -# If set, VIVO will use this endpoint as its triple store instead of the -# SDB database. -# -#VitroConnection.DataSource.endpointURI = - -# -# Optional URI to use for modifying the above endpoint via SPARQL UPDATE. -# This setting is only necessary if the endpoint does not support updates via -# its main URI. (This may be done for access control purposes.) -# If the endpointURI above is not set, this setting has no effect. -# -#VitroConnection.DataSource.updateEndpointURI = - -# -# The email address of the root user for the VIVO application. The password -# for this user is initially set to "rootPassword", but you will be asked to -# change the password the first time you log in. -# -rootUser.emailAddress = root@myDomain.com - -# -# How is a logged-in user associated with a particular Individual? One way is -# for the Individual to have a property whose value is the username of the user. -# This is the name of that property. -# -selfEditing.idMatchingProperty = http://vitro.mydomain.edu/ns#networkId - -# -# If an external authentication system like Shibboleth or CUWebAuth is to be -# used, these properties say how the login button should be labeled, and which -# HTTP header will contain the user ID from the authentication system. If such -# as system is not to be used, leave these commented out. Consult the -# installation instructions for more details. -# -#externalAuth.buttonText = Log in using BearCat Shibboleth -#externalAuth.netIdHeaderName = remote_userID - -# -# Types of individual for which we can create proxy editors. -# If this is omitted, defaults to http://www.w3.org/2002/07/owl#Thing -proxy.eligibleTypeList = http://www.w3.org/2002/07/owl#Thing - -# -# Show only the most appropriate data values based on the Accept-Language -# header supplied by the browser. Default is true if not set. -# -RDFService.languageFilter = true - -# -# Tell VIVO to generate HTTP headers on its responses to facilitate caching the -# profile pages that it creates. -# -# For more information, see -# https://wiki.duraspace.org/display/VIVO/Use+HTTP+caching+to+improve+performance -# -# Developers will likely want to leave caching disabled, since a change to a -# Freemarker template or to a Java class would not cause the page to be -# considered stale. -# -# http.createCacheHeaders = true - -# -# Force VIVO to use a specific language or Locale instead of those -# specified by the browser. This affects RDF data retrieved from the model, -# if RDFService.languageFilter is true. This also affects the text of pages -# that have been modified to support multiple languages. -# -# languages.forceLocale = en_US - -# -# A list of supported languages or Locales that the user may choose to -# use instead of the one specified by the browser. Selection images must -# be available in the i18n/images directory of the theme. This affects -# RDF data retrieved from the model, if RDFService.languageFilter is true. -# This also affects the text of pages that have been modified to support -# multiple languages. -# -# This should not be used with languages.forceLocale, which will override it. -# -# languages.selectableLocales = en, es, fr - -# -# For developers only: Setting this option to "true" slows down Vitro performance. -# -# Defeat the Freemarker template cache, so each template is read from disk -# on each request. This permits developers to immediately see the effect of -# changes to the template. The default is false, which means -# that a cached copy of each template will be used for 60 seconds before -# the disk is checked for a new version. -# -# developer.defeatFreemarkerCache = true - -# -# For developers only: Setting this option to "true" slows down Vitro performance. -# -# Defeat the cache of language-specific text strings, so the language file -# is read from disk on each request. This permits developers to immediately -# see the effect of changes to the text strings. The default is -# false, which means that the language file is read when -# VIVO starts up, or when a new theme is selected. -# -# developer.defeatI18nCache = true - -# -# For developers only: Setting this option to "true" slows down Vitro performance. -# -# Add starting and ending delimiters to each Freemarker template, so you can see -# which template were invoked by viewing the generated HTML. The default is -# false. -# -# developer.insertFreemarkerDelimiters = true - +# ----------------------------------------------------------------------------- +# +# Vitro runtime properties +# +# This file is provided as example.runtime.properties. +# +# Save a copy of this file as runtime.properties in your Vitro home directory, +# and edit the properties as needed for your installation. +# +# ----------------------------------------------------------------------------- + +# +# This namespace will be used when generating URIs for objects created in the +# editor. In order to serve linked data, the default namespace must be composed +# as follows (optional elements in parentheses): +# +# scheme + server_name (+ port) (+ servlet_context) + "/individual/" +# +# For example, Cornell's default namespace is: +# +# http://vivo.cornell.edu/individual/ +# +Vitro.defaultNamespace = http://vivo.mydomain.edu/individual/ + +# +# URL of Solr context used in local Vitro search. This will usually consist of: +# scheme + server_name + port + vitro_webapp_name + "solr" +# In the standard installation, the Solr context will be on the same server as Vitro, +# and in the same Tomcat instance. The path will be the Vitro webapp.name (specified +# above) + "solr" +# Example: +# vitro.local.solr.url = http://localhost:8080/vitrosolr +vitro.local.solr.url = http://localhost:8080/vitrosolr + +# +# Email parameters which VIVO can use to send mail. If these are left empty, +# the "Contact Us" form will be disabled and users will not be notified of +# changes to their accounts. +# +email.smtpHost = smtp.my.domain.edu +email.replyTo = vivoAdmin@my.domain.edu + +# +# The basic parameters for a MySQL database connection. Change the end of the +# URL to reflect your database name (if it is not "vitro"). Change the username +# and password to match the authorized user you created in MySQL. +# +VitroConnection.DataSource.url = jdbc:mysql://localhost/vitro +VitroConnection.DataSource.username = vitroweb +VitroConnection.DataSource.password = vitrovitro + +# +# The maximum number of active connections in the database connection pool. +# Increase this value to support a greater number of concurrent page requests. +# +VitroConnection.DataSource.pool.maxActive = 40 + +# +# The maximum number of database connections that will be allowed +# to remain idle in the connection pool. Default is 25% +# of the maximum number of active connections. +# +VitroConnection.DataSource.pool.maxIdle = 10 + +# +# Parameters to change in order to use VIVO with a database other than +# MySQL. +# +VitroConnection.DataSource.dbtype = MySQL +VitroConnection.DataSource.driver = com.mysql.jdbc.Driver +VitroConnection.DataSource.validationQuery = SELECT 1 + +# +# Optional URI of a SPARQL endpoint from which VIVO should display data. +# If set, VIVO will use this endpoint as its triple store instead of the +# SDB database. +# +#VitroConnection.DataSource.endpointURI = + +# +# Optional URI to use for modifying the above endpoint via SPARQL UPDATE. +# This setting is only necessary if the endpoint does not support updates via +# its main URI. (This may be done for access control purposes.) +# If the endpointURI above is not set, this setting has no effect. +# +#VitroConnection.DataSource.updateEndpointURI = + +# +# The email address of the root user for the VIVO application. The password +# for this user is initially set to "rootPassword", but you will be asked to +# change the password the first time you log in. +# +rootUser.emailAddress = root@myDomain.com + +# +# How is a logged-in user associated with a particular Individual? One way is +# for the Individual to have a property whose value is the username of the user. +# This is the name of that property. +# +selfEditing.idMatchingProperty = http://vitro.mydomain.edu/ns#networkId + +# +# If an external authentication system like Shibboleth or CUWebAuth is to be +# used, this property says which HTTP header will contain the user ID from +# the authentication system. If such a system is not to be used, leave this +# commented out. Consult the installation instructions for more details. +# +#externalAuth.netIdHeaderName = remote_userID + +# +# Types of individual for which we can create proxy editors. +# If this is omitted, defaults to http://www.w3.org/2002/07/owl#Thing +proxy.eligibleTypeList = http://www.w3.org/2002/07/owl#Thing + +# +# Show only the most appropriate data values based on the Accept-Language +# header supplied by the browser. Default is true if not set. +# +RDFService.languageFilter = true + +# +# Tell VIVO to generate HTTP headers on its responses to facilitate caching the +# profile pages that it creates. +# +# For more information, see +# https://wiki.duraspace.org/display/VIVO/Use+HTTP+caching+to+improve+performance +# +# Developers will likely want to leave caching disabled, since a change to a +# Freemarker template or to a Java class would not cause the page to be +# considered stale. +# +# http.createCacheHeaders = true + +# +# Force VIVO to use a specific language or Locale instead of those +# specified by the browser. This affects RDF data retrieved from the model, +# if RDFService.languageFilter is true. This also affects the text of pages +# that have been modified to support multiple languages. +# +# languages.forceLocale = en_US + +# +# A list of supported languages or Locales that the user may choose to +# use instead of the one specified by the browser. Selection images must +# be available in the i18n/images directory of the theme. This affects +# RDF data retrieved from the model, if RDFService.languageFilter is true. +# This also affects the text of pages that have been modified to support +# multiple languages. +# +# This should not be used with languages.forceLocale, which will override it. +# +# languages.selectableLocales = en, es, fr + +# +# For developers only: Setting this option to "true" slows down Vitro performance. +# +# Defeat the Freemarker template cache, so each template is read from disk +# on each request. This permits developers to immediately see the effect of +# changes to the template. The default is false, which means +# that a cached copy of each template will be used for 60 seconds before +# the disk is checked for a new version. +# +# developer.defeatFreemarkerCache = true + +# +# For developers only: Setting this option to "true" slows down Vitro performance. +# +# Defeat the cache of language-specific text strings, so the language file +# is read from disk on each request. This permits developers to immediately +# see the effect of changes to the text strings. The default is +# false, which means that the language file is read when +# VIVO starts up, or when a new theme is selected. +# +# developer.defeatI18nCache = true + +# +# For developers only: Setting this option to "true" slows down Vitro performance. +# +# Add starting and ending delimiters to each Freemarker template, so you can see +# which template were invoked by viewing the generated HTML. The default is +# false. +# +# developer.insertFreemarkerDelimiters = true + diff --git a/webapp/languages/example/i18n/all_es.properties b/webapp/languages/example/i18n/all_es.properties index 8db6586e3..6f2684d94 100644 --- a/webapp/languages/example/i18n/all_es.properties +++ b/webapp/languages/example/i18n/all_es.properties @@ -651,6 +651,7 @@ javascript_require_to_edit = Para editar el contenido, tendrá que activar JavaS javascript_instructions = java script de instrucciones to_enable_javascript = Aquí están las instrucciones para habilitar JavaScript en su navegador web external_auth_name = Nombre de autenticación externo +external_login_text = Entrar usando Shibboleth GatoOso account = cuenta change_password_to_login = Cambiar contraseña para iniciar sesión en new_password_capitalized = Nueva contraseña diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java index 6b314b282..83ded4a02 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java @@ -2,12 +2,12 @@ package edu.cornell.mannlib.vitro.webapp.web.widgets; -import java.io.IOException; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -126,8 +126,7 @@ public class LoginWidget extends Widget { /** * User is starting the login process. Show them the login screen. */ - private WidgetTemplateValues showLoginScreen(HttpServletRequest request, String siteName) - throws IOException { + private WidgetTemplateValues showLoginScreen(HttpServletRequest request, String siteName) { LoginProcessBean bean = LoginProcessBean.getBean(request); log.trace("Going to login screen: " + bean); @@ -135,13 +134,12 @@ public class LoginWidget extends Widget { values.put(TemplateVariable.FORM_ACTION.toString(), getAuthenticateUrl(request)); values.put(TemplateVariable.LOGIN_NAME.toString(), bean.getUsername()); - String externalAuthDisplayName = ConfigurationProperties.getBean( - request).getProperty("externalAuth.buttonText"); - if (externalAuthDisplayName != null) { + boolean showExternalAuth = StringUtils.isNotBlank( + ConfigurationProperties.getBean(request).getProperty( + "externalAuth.netIdHeaderName")); + if (showExternalAuth) { values.put(TemplateVariable.EXTERNAL_AUTH_URL.toString(), UrlBuilder.getUrl(EXTERNAL_AUTH_SETUP_URL)); - values.put(TemplateVariable.EXTERNAL_AUTH_NAME.toString(), - externalAuthDisplayName); } String infoMessage = bean.getInfoMessageAndClear(); diff --git a/webapp/web/i18n/all.properties b/webapp/web/i18n/all.properties index 480e49341..5799fc6cd 100644 --- a/webapp/web/i18n/all.properties +++ b/webapp/web/i18n/all.properties @@ -661,6 +661,7 @@ javascript_require_to_edit = In order to edit content, you'll need to enable Jav javascript_instructions = java script instructions to_enable_javascript = Here are the instructions for enabling JavaScript in your web browser external_auth_name = external authentication name +external_login_text = Log in using BearCat Shibboleth account = account change_password_to_login = Change Password to Log in new_password_capitalized = New Password diff --git a/webapp/web/templates/freemarker/widgets/widget-login.ftl b/webapp/web/templates/freemarker/widgets/widget-login.ftl index a08d44ed2..46c31d8c3 100644 --- a/webapp/web/templates/freemarker/widgets/widget-login.ftl +++ b/webapp/web/templates/freemarker/widgets/widget-login.ftl @@ -47,7 +47,7 @@ <#if externalAuthUrl??> <#assign infoClassHide = 'class="vivoAccount"'/> -

    ${externalAuthName}

    +

    ${i18n().external_login_text}

    ${i18n().or} ${siteName} ${i18n().account}

  • If an external authentication system like Shibboleth or CUWebAuth is to be - used, these properties say how the login button should be labeled, and which - HTTP header will contain the user ID from the authentication system. If such - a system is not to be used, leave these commented out. Consult the installation - instructions for more details. + used, this property says which HTTP header will contain the user ID from + the authentication system. If such a system is not to be used, + leave this commented out.
    - externalAuth.buttonText -
    externalAuth.netIdHeaderName
    - Log in using BearCat Shibboleth -
    remote_userID