branch develop updated (c43a0f5 -> 540789a)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository bow. See http://git.chorem.org/bow.git from c43a0f5 fixes #1270: the user must configure the atom stream to not receive its own links new 540789a fixes #233: Add support for login/password (change header jsp generation) (add minification css/js) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 540789ad4e35f5df72289f248aedb5bbd551b177 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Fri Jul 31 03:54:30 2015 +0200 fixes #233: Add support for login/password (change header jsp generation) (add minification css/js) Summary of changes: bow-ui/pom.xml | 51 +++ bow-ui/src/main/java/org/chorem/bow/BowUtils.java | 27 ++ .../action/preference/PreferenceBaseAction.java | 30 +- ...Action.java => UpdateAuthenticationAction.java} | 42 ++- .../main/resources/i18n/bow-ui_en_GB.properties | 7 + .../main/resources/i18n/bow-ui_fr_FR.properties | 7 + bow-ui/src/main/resources/struts.xml | 5 + bow-ui/src/main/webapp/WEB-INF/bowutils.tld | 6 + bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp | 7 +- bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp | 3 - .../src/main/webapp/WEB-INF/jsp/editBookmark.jsp | 3 - bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp | 3 - .../src/main/webapp/WEB-INF/jsp/forgotPassword.jsp | 1 - bow-ui/src/main/webapp/WEB-INF/jsp/groupEdit.jsp | 3 - bow-ui/src/main/webapp/WEB-INF/jsp/groupView.jsp | 3 - bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp | 3 - bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp | 1 - bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp | 33 +- bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp | 1 - .../src/main/webapp/WEB-INF/jsp/sharedUserEdit.jsp | 3 - .../src/main/webapp/WEB-INF/jsp/sharedUserView.jsp | 6 +- bow-ui/src/main/webapp/js/bowpwd.js | 47 +++ bow-ui/src/main/webapp/js/sha256.js | 343 +++++++++++++++++++++ 23 files changed, 586 insertions(+), 49 deletions(-) copy bow-ui/src/main/java/org/chorem/bow/action/preference/{GenerateTokenAction.java => UpdateAuthenticationAction.java} (57%) create mode 100644 bow-ui/src/main/webapp/js/bowpwd.js create mode 100644 bow-ui/src/main/webapp/js/sha256.js -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository bow. See http://git.chorem.org/bow.git commit 540789ad4e35f5df72289f248aedb5bbd551b177 Author: Benjamin POUSSIN <poussin@codelutin.com> Date: Fri Jul 31 03:54:30 2015 +0200 fixes #233: Add support for login/password (change header jsp generation) (add minification css/js) --- bow-ui/pom.xml | 51 +++ bow-ui/src/main/java/org/chorem/bow/BowUtils.java | 27 ++ .../action/preference/PreferenceBaseAction.java | 30 +- .../preference/UpdateAuthenticationAction.java | 78 +++++ .../main/resources/i18n/bow-ui_en_GB.properties | 7 + .../main/resources/i18n/bow-ui_fr_FR.properties | 7 + bow-ui/src/main/resources/struts.xml | 5 + bow-ui/src/main/webapp/WEB-INF/bowutils.tld | 6 + bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp | 7 +- bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp | 3 - .../src/main/webapp/WEB-INF/jsp/editBookmark.jsp | 3 - bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp | 3 - .../src/main/webapp/WEB-INF/jsp/forgotPassword.jsp | 1 - bow-ui/src/main/webapp/WEB-INF/jsp/groupEdit.jsp | 3 - bow-ui/src/main/webapp/WEB-INF/jsp/groupView.jsp | 3 - bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp | 3 - bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp | 1 - bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp | 33 +- bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp | 1 - .../src/main/webapp/WEB-INF/jsp/sharedUserEdit.jsp | 3 - .../src/main/webapp/WEB-INF/jsp/sharedUserView.jsp | 6 +- bow-ui/src/main/webapp/js/bowpwd.js | 47 +++ bow-ui/src/main/webapp/js/sha256.js | 343 +++++++++++++++++++++ 23 files changed, 637 insertions(+), 34 deletions(-) diff --git a/bow-ui/pom.xml b/bow-ui/pom.xml index a733e8b..7c83b49 100644 --- a/bow-ui/pom.xml +++ b/bow-ui/pom.xml @@ -323,6 +323,57 @@ </execution> </executions> </plugin> + + <plugin> + <groupId>com.samaxes.maven</groupId> + <artifactId>minify-maven-plugin</artifactId> + <version>1.7.4</version> + <executions> + <execution> + <id>default-minify</id> + <!--<phase>package</phase> When omitted defaults to 'process-resources' --> + <configuration> + <charset>UTF-8</charset> + <cssSourceDir>css</cssSourceDir> + <cssSourceFiles> + <cssSourceFile>bookmark.css</cssSourceFile> + <cssSourceFile>jquery-ui-1.8.11.custom.bow.css</cssSourceFile> + <cssSourceFile>global.css</cssSourceFile> + </cssSourceFiles> + <cssFinalFile>bow.css</cssFinalFile> + <jsSourceDir>js</jsSourceDir> + <jsSourceFiles> + <jsSourceFile>bookmark.js</jsSourceFile> + </jsSourceFiles> + <jsFinalFile>bow.js</jsFinalFile> + <jsEngine>CLOSURE</jsEngine> + </configuration> + <goals> + <goal>minify</goal> + </goals> + </execution> + <execution> + <id>scriptlet-minify</id> + <!--<phase>package</phase> When omitted defaults to 'process-resources' --> + <configuration> + <charset>UTF-8</charset> + <jsSourceDir>js</jsSourceDir> + <webappTargetDir>${project.build.directory}</webappTargetDir> + <jsTargetDir>classes</jsTargetDir> + <jsSourceFiles> + <jsSourceFile>sha256.js</jsSourceFile> + <jsSourceFile>bowpwd.js</jsSourceFile> + </jsSourceFiles> + <jsFinalFile>bowpwd-sha256.js</jsFinalFile> + <jsEngine>CLOSURE</jsEngine> + </configuration> + <goals> + <goal>minify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> </build> diff --git a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java index 1e9b0df..94b328e 100644 --- a/bow-ui/src/main/java/org/chorem/bow/BowUtils.java +++ b/bow-ui/src/main/java/org/chorem/bow/BowUtils.java @@ -22,6 +22,10 @@ package org.chorem.bow; import com.github.rjeschke.txtmark.Configuration; import com.github.rjeschke.txtmark.Processor; +import java.io.File; +import java.net.URI; +import java.net.URL; +import java.net.URLEncoder; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; @@ -35,12 +39,18 @@ import java.util.Set; import java.util.UUID; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; import org.nuiton.wikitty.services.WikittyServiceAuthorisation; public class BowUtils { + private static final Log log = LogFactory.getLog(BowUtils.class); + public static final String BOW_DATE_SHORT_PATTERN = "yyyy/MM/dd"; /** @@ -60,6 +70,23 @@ public class BowUtils { return result; } + public static String scriptletPassword(BowAuthentication auth) { + String result = ""; + try { + URL script = BowUtils.class.getResource("/bowpwd-sha256.min.js"); + String js = IOUtils.toString(script) + + String.format(";window.bow.bowpwd('', '%s', '%s', '%s', '%s', '%s');", + auth.getMaxLength(), auth.getPrefix(), auth.getInclude(), + auth.getExclude(), auth.getSuffix()); + + URI uri = new URI("javascript", js, null); + result = uri.toASCIIString(); + } catch (Exception eee) { + log.info("Can't create scriptlet password", eee); + } + return result; + } + public static String toBase64(byte[] b) { return Base64.encodeBase64String(b); } diff --git a/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java b/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java index 4b09774..10bf854 100644 --- a/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java +++ b/bow-ui/src/main/java/org/chorem/bow/action/preference/PreferenceBaseAction.java @@ -37,6 +37,8 @@ import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.bow.BowAuthentication; +import org.chorem.bow.BowAuthenticationImpl; import org.chorem.bow.BowSearchPrefix; import org.nuiton.wikitty.query.FacetTopic; import org.nuiton.wikitty.query.WikittyQuery; @@ -62,9 +64,11 @@ public class PreferenceBaseAction extends BowBaseAction { /** la liste des differentes data que l'on peut charger */ protected enum PreferenceType { - USER_PREF, SITE_PREF, LABELS, IMPORTS + USER_PREF, AUTH_PREF, SITE_PREF, LABELS, IMPORTS } + protected BowAuthentication bowAuth; + protected String email; protected String newPassword; @@ -99,6 +103,24 @@ public class PreferenceBaseAction extends BowBaseAction { protected Map<String, Integer> bookmarksImportDate; + public BowAuthentication getBowAuth() { + if (bowAuth == null) { + BowSession session = getBowSession(); + BowUser user = session.getUser(); + + bowAuth = user.getBowAuthentication(false); + if (bowAuth == null) { + bowAuth = new BowAuthenticationImpl(); + user.setBowAuthentication(bowAuth); + } + } + return bowAuth; + } + + public void setBowAuth(BowAuthentication bowAuth) { + this.bowAuth = bowAuth; + } + public String getNewLabel() { return newLabel; } @@ -289,6 +311,9 @@ public class PreferenceBaseAction extends BowBaseAction { case USER_PREF: loadUserPref(); break; + case AUTH_PREF: + loadAuthPref(); + break; case SITE_PREF: loadSitePref(); loadSearchPrefixPref(); @@ -315,6 +340,9 @@ public class PreferenceBaseAction extends BowBaseAction { setEmail(user.getLogin()); } + protected void loadAuthPref() { + } + /** Charge les preferences utilisateur pour le site */ protected void loadSitePref() { BowSession session = getBowSession(); diff --git a/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateAuthenticationAction.java b/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateAuthenticationAction.java new file mode 100644 index 0000000..51140a9 --- /dev/null +++ b/bow-ui/src/main/java/org/chorem/bow/action/preference/UpdateAuthenticationAction.java @@ -0,0 +1,78 @@ +/* + * #%L + * BOW UI + * %% + * Copyright (C) 2010 - 2011 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package org.chorem.bow.action.preference; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.bow.BowProxy; +import org.chorem.bow.BowSession; +import org.chorem.bow.BowUser; + +/** + * @author poussin + * @version $Revision$ + * <p/> + * Last update: $Date$ + * by : $Author$ + */ +public class UpdateAuthenticationAction extends PreferenceBaseAction { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(UpdateAuthenticationAction.class); + + private static final long serialVersionUID = 1L; + + /** + * ACTION STRUTS + * <p/> + * Modifie l'email et le password si necessaire. Si la modif est impossible + * email deja utilise, ou mauvais password, alors la methode return ERROR + * Si tout ce passe bien, la methode retourne SUCCES + * + * @return + */ + @Override + public String execute() { + String result = SUCCESS; + + try { + BowSession session = getBowSession(); + BowProxy proxy = session.getProxy(); + BowUser user = session.getUser(); + user.setBowAuthentication(bowAuth); + + proxy.store(user, bowAuth); + + addActionMessage(t("bow.preferences.update.successful")); + } catch (Exception eee) { + result = ERROR; + addActionError(t("bow.error.internal")); + log.error("Can't change authentication preference", eee); + } finally { + // on recharge les data apres l'action pour l'affichage + // sauf celle du user qui sont deja les bonnes + load(PreferenceType.AUTH_PREF); + } + + return result; + } + +} diff --git a/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties b/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties index 587e7c8..22696f4 100644 --- a/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties +++ b/bow-ui/src/main/resources/i18n/bow-ui_en_GB.properties @@ -92,7 +92,14 @@ bow.permanent.link.search=Permanent search URL bow.permanent.link.searchDescription=Permalink to use Bow as search engine in your browser bow.permanent.link.suggestion=Permanent suggest URL bow.permanent.link.suggestionDescription=Permalink to use Bow as suggest engine in your browser +bow.preference.authentication.exclude= +bow.preference.authentication.include= +bow.preference.authentication.login= +bow.preference.authentication.maxlength= bow.preference.opensearch.prefix.separator=OpenSeach prefix separator +bow.preferences.authentication= +bow.preferences.authentication.prefix= +bow.preferences.authentication.suffix= bow.preferences.badCurrentPassword=Your current password is incorrect bow.preferences.bookmarksHomePage=Number of bookmarks displayed on the home page bow.preferences.colors=Site color diff --git a/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties b/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties index 7ec65bf..f406c22 100644 --- a/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties +++ b/bow-ui/src/main/resources/i18n/bow-ui_fr_FR.properties @@ -92,7 +92,14 @@ bow.permanent.link.search=URL de recherche permanente bow.permanent.link.searchDescription=Lien permanent pour utiliser Bow comme moteur de recherche dans votre navigateur bow.permanent.link.suggestion=URL de suggesion permanente bow.permanent.link.suggestionDescription=Lien permanent pour utiliser Bow comme moteur de suggestion dans votre navigateur +bow.preference.authentication.exclude= +bow.preference.authentication.include= +bow.preference.authentication.login= +bow.preference.authentication.maxlength= bow.preference.opensearch.prefix.separator=Separateur de préfix +bow.preferences.authentication= +bow.preferences.authentication.prefix= +bow.preferences.authentication.suffix= bow.preferences.badCurrentPassword=Votre mot de passe actuel est incorrect bow.preferences.bookmarksHomePage=Nombre de marque-pages affichés bow.preferences.colors=Couleur du site diff --git a/bow-ui/src/main/resources/struts.xml b/bow-ui/src/main/resources/struts.xml index 5f8a358..6f7adb0 100644 --- a/bow-ui/src/main/resources/struts.xml +++ b/bow-ui/src/main/resources/struts.xml @@ -259,6 +259,11 @@ <result>/WEB-INF/jsp/preferences.jsp</result> </action> + <action name="updateAuthenticationPref" class="org.chorem.bow.action.preference.UpdateAuthenticationAction"> + <result name="error">/WEB-INF/jsp/preferences.jsp</result> + <result>/WEB-INF/jsp/preferences.jsp</result> + </action> + <action name="updateSitePref" class="org.chorem.bow.action.preference.UpdateSiteAction"> <result name="error">/WEB-INF/jsp/preferences.jsp</result> <result>/WEB-INF/jsp/preferences.jsp</result> diff --git a/bow-ui/src/main/webapp/WEB-INF/bowutils.tld b/bow-ui/src/main/webapp/WEB-INF/bowutils.tld index 612f6c0..68b88b2 100644 --- a/bow-ui/src/main/webapp/WEB-INF/bowutils.tld +++ b/bow-ui/src/main/webapp/WEB-INF/bowutils.tld @@ -25,4 +25,10 @@ <function-class>org.chorem.bow.BowUtils</function-class> <function-signature>java.lang.String toHtml(java.lang.String)</function-signature> </function> + + <function> + <name>scriptletPassword</name> + <function-class>org.chorem.bow.BowUtils</function-class> + <function-signature>java.lang.String scriptletPassword(org.chorem.bow.BowAuthentication)</function-signature> + </function> </taglib> diff --git a/bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp b/bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp index f77707c..c87825e 100644 --- a/bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/decorators/main.jsp @@ -37,19 +37,22 @@ <decorator:head /> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta name="description" content="Bookmarks on the web" /> - <s:url var="temporaryXml" action="temporaryXml" /> - <s:url var="permanentXml" action="permanentXml" /> <s:url var="favicon" value="/img/favicon.png" /> <link rel="icon" type="image/png" href="${favicon}" /> <s:if test="%{#session.BowSession.user != null}"> + <s:url var="temporaryXml" action="temporaryXml" /> + <s:url var="permanentXml" action="permanentXml" /> <link rel="search" type="application/opensearchdescription+xml" title="Bow (temporary)" href="${temporaryXml}" /> <link rel="search" type="application/opensearchdescription+xml" title="Bow (permanent)" href="${permanentXml}" /> </s:if> + <s:head /> <sj:head/> + <s:url var="bookmarkCSS" value="/css/bookmark.css" /> <s:url var="jqueryUiCSS" value="/css/jquery-ui-1.8.11.custom.bow.css" /> <s:url var="globalCSS" value="/css/global.css" /> + <link href="${bookmarkCSS}" rel="stylesheet" type="text/css"/> <link href="${jqueryUiCSS}" rel="stylesheet" type="text/css" media="all" /> <link href="${globalCSS}" rel="stylesheet" type="text/css" media="all" /> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp index 9ad7701..77dbc32 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/admin.jsp @@ -26,9 +26,6 @@ xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <head> - <s:url var="css" value="/css/bookmark.css" /> - <link href="${css}" rel="stylesheet" type="text/css" /> - <s:head /> </head> <body> <div id="content"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/editBookmark.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/editBookmark.jsp index f627995..4bf32b9 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/editBookmark.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/editBookmark.jsp @@ -26,9 +26,6 @@ xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <head> - <s:url var="css" value="/css/bookmark.css" /> - <link href="${css}" rel="stylesheet" type="text/css" /> - <s:head /> </head> <body> <div id="content"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp index 89e583a..c8c024e 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/error.jsp @@ -26,9 +26,6 @@ xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <head> - <s:url var="css" value="/css/connexion.css" /> - <link href="${css}" rel="stylesheet" type="text/css" /> - <s:head /> </head> <body> <div id="main"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/forgotPassword.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/forgotPassword.jsp index ad82cc9..f9361f5 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/forgotPassword.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/forgotPassword.jsp @@ -29,7 +29,6 @@ <title><s:text name="bow.forgotpwd.title" /></title> <s:url var="css" value="/css/connexion.css" /> <link href="${css}" rel="stylesheet" type="text/css" /> - <s:head /> </head> <body> <div id="content"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/groupEdit.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/groupEdit.jsp index c86e841..fa4b762 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/groupEdit.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/groupEdit.jsp @@ -29,9 +29,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. xmlns:jsp="http://java.sun.com/JSP/Page"> <head> <title><s:text name="bow.groupEdit.title"/></title> - <s:url var="css" value="/css/bookmark.css" /> - <link href="${css}" rel="stylesheet" type="text/css"/> - <s:head/> <script> function addUserEnter(e) { if (e.keyCode === 13) { diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/groupView.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/groupView.jsp index f5a0b72..4a55b9d 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/groupView.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/groupView.jsp @@ -30,9 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. xmlns:jsp="http://java.sun.com/JSP/Page"> <head> <title><s:text name="bow.groupView.title"/></title> - <s:url var="css" value="/css/bookmark.css" /> - <link href="${css}" rel="stylesheet" type="text/css"/> - <s:head/> </head> <body> <div id="content"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp index 35a5e70..eec243a 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/home.jsp @@ -27,9 +27,6 @@ <head> <title><s:text name="bow.search.title" /></title> - <s:url var="css" value="/css/bookmark.css" /> - <link href="${css}" rel="stylesheet" type="text/css" /> - <s:head /> </head> <body> <div class="menu clearfix"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp index 0cd158a..46df375 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/login.jsp @@ -27,7 +27,6 @@ <title><s:text name="bow.login.title" /></title> <s:url var="css" value="/css/connexion.css" /> <link href="${css}" rel="stylesheet" type="text/css" /> - <s:head /> </head> <body> <div id="content"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp index 7e46862..3fd4041 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/preferences.jsp @@ -19,14 +19,12 @@ <%@page import="org.chorem.bow.action.preference.PreferenceBaseAction"%> <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@taglib prefix="s" uri="/struts-tags" %> +<%@taglib prefix="u" uri="/WEB-INF/bowutils" %> <html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" xmlns:jsp="http://java.sun.com/JSP/Page"> <head> <title><s:text name="bow.preferences.title"/></title> - <s:url var="css" value="/css/bookmark.css"/> - <link href="${css}" rel="stylesheet" type="text/css"/> - <s:head/> </head> <body> <div id="content"> @@ -120,7 +118,36 @@ <s:submit key="bow.preferences.submit" name="submit"/> </s:form> </div> + <div class="formFrame fond"> + <h3><s:text name="bow.preferences.authentication"/> <a href="${u:scriptletPassword(bowAuth)}">BowPwd</a></h3> + <br/> + <s:form action="updateAuthenticationPref" cssClass="pretty-form" method="post"> + <s:textfield name="bowAuth.login" key="bow.preference.authentication.login" + labelposition="top" tooltip="bow.preference.authentication.login.tooltip"/> + + <s:textfield name="bowAuth.maxLength" key="bow.preference.authentication.maxLength" + labelposition="top" tooltip="bow.preference.authentication.maxLength.tooltip"/> + + <s:textfield name="bowAuth.include" key="bow.preference.authentication.include" + labelposition="top" tooltip="bow.preference.authentication.include.tooltip"/> + + <s:textfield name="bowAuth.exclude" key="bow.preference.authentication.exclude" + labelposition="top" tooltip="bow.preference.authentication.exclude.tooltip"/> + + <s:textfield name="bowAuth.prefix" key="bow.preferences.authentication.prefix" + labelposition="top" tooltip="bow.preferences.authentication.prefix.tooltip"/> + + <s:textfield name="bowAuth.suffix" key="bow.preferences.authentication.suffix" + labelposition="top" tooltip="bow.preferences.authentication.suffix.tooltip"/> + + <s:hidden name="update" value="authentication"/> + <s:submit key="bow.preferences.submit" name="submit"/> + </s:form> + </div> + + + <div class="formFrame fond"> <h3><s:text name="bow.preferences.siteLook"/></h3> <br/> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp index 6b87026..0eee145 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/register.jsp @@ -29,7 +29,6 @@ <title><s:text name="bow.register.title" /></title> <s:url var="css" value="/css/connexion.css" /> <link href="${css}" rel="stylesheet" type="text/css" /> - <s:head /> </head> <body> <div id="content"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/sharedUserEdit.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/sharedUserEdit.jsp index 5e0d5e8..a0a9325 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/sharedUserEdit.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/sharedUserEdit.jsp @@ -29,9 +29,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. xmlns:jsp="http://java.sun.com/JSP/Page"> <head> <title><s:text name="bow.sharedUserEdit.title"/></title> - <s:url var="css" value="/css/bookmark.css" /> - <link href="${css}" rel="stylesheet" type="text/css"/> - <s:head/> </head> <body> <div id="content"> diff --git a/bow-ui/src/main/webapp/WEB-INF/jsp/sharedUserView.jsp b/bow-ui/src/main/webapp/WEB-INF/jsp/sharedUserView.jsp index 6414cf4..ad63f78 100644 --- a/bow-ui/src/main/webapp/WEB-INF/jsp/sharedUserView.jsp +++ b/bow-ui/src/main/webapp/WEB-INF/jsp/sharedUserView.jsp @@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #L% --%> +<%@page import="java.util.Collections"%> <%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@taglib prefix="s" uri="/struts-tags" %> <%@taglib uri="/WEB-INF/bowutils" prefix="u" %> @@ -30,9 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. xmlns:jsp="http://java.sun.com/JSP/Page"> <head> <title><s:text name="bow.sharedUserView.title"/></title> - <s:url var="css" value="/css/bookmark.css" /> - <link href="${css}" rel="stylesheet" type="text/css"/> - <s:head/> </head> <body> <div id="content"> @@ -40,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. <h2><s:text name="bow.sharedUserView.title"/></h2> </div> <s:actionerror/> - + <%=org.chorem.bow.BowUtils.class.getResource("/struts.xml")%> <div class="formFrame fond"> <s:a action="sharedUserEdit"><s:text name="bow.sharedUser.new" /></s:a> <ul> diff --git a/bow-ui/src/main/webapp/js/bowpwd.js b/bow-ui/src/main/webapp/js/bowpwd.js new file mode 100644 index 0000000..5d0651e --- /dev/null +++ b/bow-ui/src/main/webapp/js/bowpwd.js @@ -0,0 +1,47 @@ +window.bow = window.bow || {}; +window.bow.bowpwd = window.bow.bowpwd || function(hostname, maximum, prefix, include, exclude, suffix) { + var e = document.activeElement; + var isInput = e.tagName === "INPUT"; + + var password = isInput && e.value || prompt("Your private password"); + var config = password.split('|'); + password = config.shift(); + var c; + while (c=config.shift()) { + if (c.match(/\s*[0-9]+\s*/)) { // only numbers => maximum + maximum = parseInt(c); + } else if (c.match(/\s*\:.+/)){ // begin with ':' => prefix + prefix = c; + } else if (c.match(/\s*=.+/)){ // begin with '=' => include + include = c.trim().substr(1); + } else if (c.match(/\s*-.+/)){ // begin with '-' => exclude + exclude = c.trim().substr(1); + } else if (c.match(/\s*\+.+/)){ // begin with '+' => suffix + suffix = c.trimLeft().substr(1); + } else { // all other is suffix (not obligation to begin with +) + suffix = c; + } + } + + password = (prefix || '') + password; + hostname = hostname || location.hostname; + maximum = maximum || e.maxLength || 99; + suffix = suffix || ''; + + var result = bow.hash(password, hostname); + if (include) { + result = result.replace(RegExp('[^' + include + ']', 'g'), ''); + } + if (exclude) { + result = result.replace(RegExp('[' + exclude + ']', 'g'), ''); + } + result = result.substr(0, maximum); + result = result + suffix; + + if (isInput) { + e.value= result; + } else { + prompt("Copy your password with Ctrl+C", result); + } +}; + diff --git a/bow-ui/src/main/webapp/js/sha256.js b/bow-ui/src/main/webapp/js/sha256.js new file mode 100644 index 0000000..0870f95 --- /dev/null +++ b/bow-ui/src/main/webapp/js/sha256.js @@ -0,0 +1,343 @@ +/* + * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined + * in FIPS 180-2 + * Version 2.2 Copyright Angel Marin, Paul Johnston 2000 - 2009. + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for details. + * Also http://anmar.eu.org/projects/jssha2/ + */ + +/* + * Configurable variables. You may need to tweak these to be compatible with + * the server-side, but the defaults work in most cases. + */ +window.bow = window.bow || {}; +window.bow.hash = window.bow.hash || (function() { +var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ +var b64pad = "="; /* base-64 pad character. "=" for strict RFC compliance */ + +/* + * These are the functions you'll usually want to call + * They take string arguments and return either hex or base-64 encoded strings + */ +function hex_sha256(s) { return rstr2hex(rstr_sha256(str2rstr_utf8(s))); } +function b64_sha256(s) { return rstr2b64(rstr_sha256(str2rstr_utf8(s))); } +function any_sha256(s, e) { return rstr2any(rstr_sha256(str2rstr_utf8(s)), e); } +function hex_hmac_sha256(k, d) + { return rstr2hex(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d))); } +function b64_hmac_sha256(k, d) + { return rstr2b64(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d))); } +function any_hmac_sha256(k, d, e) + { return rstr2any(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d)), e); } + +/* + * Perform a simple self-test to see if the VM is working + */ +function sha256_vm_test() +{ + return hex_sha256("abc").toLowerCase() == + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; +} + +/* + * Calculate the sha256 of a raw string + */ +function rstr_sha256(s) +{ + return binb2rstr(binb_sha256(rstr2binb(s), s.length * 8)); +} + +/* + * Calculate the HMAC-sha256 of a key and some data (raw strings) + */ +function rstr_hmac_sha256(key, data) +{ + var bkey = rstr2binb(key); + if(bkey.length > 16) bkey = binb_sha256(bkey, key.length * 8); + + var ipad = Array(16), opad = Array(16); + for(var i = 0; i < 16; i++) + { + ipad[i] = bkey[i] ^ 0x36363636; + opad[i] = bkey[i] ^ 0x5C5C5C5C; + } + + var hash = binb_sha256(ipad.concat(rstr2binb(data)), 512 + data.length * 8); + return binb2rstr(binb_sha256(opad.concat(hash), 512 + 256)); +} + +/* + * Convert a raw string to a hex string + */ +function rstr2hex(input) +{ + try { hexcase } catch(e) { hexcase=0; } + var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; + var output = ""; + var x; + for(var i = 0; i < input.length; i++) + { + x = input.charCodeAt(i); + output += hex_tab.charAt((x >>> 4) & 0x0F) + + hex_tab.charAt( x & 0x0F); + } + return output; +} + +/* + * Convert a raw string to a base-64 string + */ +function rstr2b64(input) +{ + try { b64pad } catch(e) { b64pad=''; } + var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + var output = ""; + var len = input.length; + for(var i = 0; i < len; i += 3) + { + var triplet = (input.charCodeAt(i) << 16) + | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0) + | (i + 2 < len ? input.charCodeAt(i+2) : 0); + for(var j = 0; j < 4; j++) + { + if(i * 8 + j * 6 > input.length * 8) output += b64pad; + else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F); + } + } + return output; +} + +/* + * Convert a raw string to an arbitrary string encoding + */ +function rstr2any(input, encoding) +{ + var divisor = encoding.length; + var remainders = Array(); + var i, q, x, quotient; + + /* Convert to an array of 16-bit big-endian values, forming the dividend */ + var dividend = Array(Math.ceil(input.length / 2)); + for(i = 0; i < dividend.length; i++) + { + dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1); + } + + /* + * Repeatedly perform a long division. The binary array forms the dividend, + * the length of the encoding is the divisor. Once computed, the quotient + * forms the dividend for the next step. We stop when the dividend is zero. + * All remainders are stored for later use. + */ + while(dividend.length > 0) + { + quotient = Array(); + x = 0; + for(i = 0; i < dividend.length; i++) + { + x = (x << 16) + dividend[i]; + q = Math.floor(x / divisor); + x -= q * divisor; + if(quotient.length > 0 || q > 0) + quotient[quotient.length] = q; + } + remainders[remainders.length] = x; + dividend = quotient; + } + + /* Convert the remainders to the output string */ + var output = ""; + for(i = remainders.length - 1; i >= 0; i--) + output += encoding.charAt(remainders[i]); + + /* Append leading zero equivalents */ + var full_length = Math.ceil(input.length * 8 / + (Math.log(encoding.length) / Math.log(2))) + for(i = output.length; i < full_length; i++) + output = encoding[0] + output; + + return output; +} + +/* + * Encode a string as utf-8. + * For efficiency, this assumes the input is valid utf-16. + */ +function str2rstr_utf8(input) +{ + var output = ""; + var i = -1; + var x, y; + + while(++i < input.length) + { + /* Decode utf-16 surrogate pairs */ + x = input.charCodeAt(i); + y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0; + if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) + { + x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF); + i++; + } + + /* Encode output as utf-8 */ + if(x <= 0x7F) + output += String.fromCharCode(x); + else if(x <= 0x7FF) + output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F), + 0x80 | ( x & 0x3F)); + else if(x <= 0xFFFF) + output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), + 0x80 | ((x >>> 6 ) & 0x3F), + 0x80 | ( x & 0x3F)); + else if(x <= 0x1FFFFF) + output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), + 0x80 | ((x >>> 12) & 0x3F), + 0x80 | ((x >>> 6 ) & 0x3F), + 0x80 | ( x & 0x3F)); + } + return output; +} + +/* + * Encode a string as utf-16 + */ +function str2rstr_utf16le(input) +{ + var output = ""; + for(var i = 0; i < input.length; i++) + output += String.fromCharCode( input.charCodeAt(i) & 0xFF, + (input.charCodeAt(i) >>> 8) & 0xFF); + return output; +} + +function str2rstr_utf16be(input) +{ + var output = ""; + for(var i = 0; i < input.length; i++) + output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, + input.charCodeAt(i) & 0xFF); + return output; +} + +/* + * Convert a raw string to an array of big-endian words + * Characters >255 have their high-byte silently ignored. + */ +function rstr2binb(input) +{ + var output = Array(input.length >> 2); + for(var i = 0; i < output.length; i++) + output[i] = 0; + for(var i = 0; i < input.length * 8; i += 8) + output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32); + return output; +} + +/* + * Convert an array of big-endian words to a string + */ +function binb2rstr(input) +{ + var output = ""; + for(var i = 0; i < input.length * 32; i += 8) + output += String.fromCharCode((input[i>>5] >>> (24 - i % 32)) & 0xFF); + return output; +} + +/* + * Main sha256 function, with its support functions + */ +function sha256_S (X, n) {return ( X >>> n ) | (X << (32 - n));} +function sha256_R (X, n) {return ( X >>> n );} +function sha256_Ch(x, y, z) {return ((x & y) ^ ((~x) & z));} +function sha256_Maj(x, y, z) {return ((x & y) ^ (x & z) ^ (y & z));} +function sha256_Sigma0256(x) {return (sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22));} +function sha256_Sigma1256(x) {return (sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25));} +function sha256_Gamma0256(x) {return (sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3));} +function sha256_Gamma1256(x) {return (sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10));} +function sha256_Sigma0512(x) {return (sha256_S(x, 28) ^ sha256_S(x, 34) ^ sha256_S(x, 39));} +function sha256_Sigma1512(x) {return (sha256_S(x, 14) ^ sha256_S(x, 18) ^ sha256_S(x, 41));} +function sha256_Gamma0512(x) {return (sha256_S(x, 1) ^ sha256_S(x, 8) ^ sha256_R(x, 7));} +function sha256_Gamma1512(x) {return (sha256_S(x, 19) ^ sha256_S(x, 61) ^ sha256_R(x, 6));} + +var sha256_K = new Array +( + 1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, + -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, + 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, + 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, + -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, + 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, + 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, + -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, + 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, + 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, + -1866530822, -1538233109, -1090935817, -965641998 +); + +function binb_sha256(m, l) +{ + var HASH = new Array(1779033703, -1150833019, 1013904242, -1521486534, + 1359893119, -1694144372, 528734635, 1541459225); + var W = new Array(64); + var a, b, c, d, e, f, g, h; + var i, j, T1, T2; + + /* append padding */ + m[l >> 5] |= 0x80 << (24 - l % 32); + m[((l + 64 >> 9) << 4) + 15] = l; + + for(i = 0; i < m.length; i += 16) + { + a = HASH[0]; + b = HASH[1]; + c = HASH[2]; + d = HASH[3]; + e = HASH[4]; + f = HASH[5]; + g = HASH[6]; + h = HASH[7]; + + for(j = 0; j < 64; j++) + { + if (j < 16) W[j] = m[j + i]; + else W[j] = safe_add(safe_add(safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]), + sha256_Gamma0256(W[j - 15])), W[j - 16]); + + T1 = safe_add(safe_add(safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)), + sha256_K[j]), W[j]); + T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c)); + h = g; + g = f; + f = e; + e = safe_add(d, T1); + d = c; + c = b; + b = a; + a = safe_add(T1, T2); + } + + HASH[0] = safe_add(a, HASH[0]); + HASH[1] = safe_add(b, HASH[1]); + HASH[2] = safe_add(c, HASH[2]); + HASH[3] = safe_add(d, HASH[3]); + HASH[4] = safe_add(e, HASH[4]); + HASH[5] = safe_add(f, HASH[5]); + HASH[6] = safe_add(g, HASH[6]); + HASH[7] = safe_add(h, HASH[7]); + } + return HASH; +} + +function safe_add (x, y) +{ + var lsw = (x & 0xFFFF) + (y & 0xFFFF); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); +} + +console.log("bow hash registered"); +return b64_hmac_sha256 +})(); -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm