Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 0a6342c

Browse files
author
Emmanuel Hugonnet
committed
Adding support for CAS SSO
1 parent 972655f commit 0a6342c

File tree

12 files changed

+99
-69
lines changed

12 files changed

+99
-69
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.silverpeas</groupId>
66
<artifactId>parent</artifactId>
7-
<version>19</version>
7+
<version>23-SNAPSHOT</version>
88
</parent>
99
<scm>
1010
<connection>scm:git:git@github.com:Silverpeas/OfficeOnline.git</connection>

src/main/java/com/silverpeas/openoffice/Launcher.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@
2626

2727
import com.silverpeas.openoffice.util.MessageDisplayer;
2828
import com.silverpeas.openoffice.util.MessageUtil;
29+
import com.silverpeas.openoffice.util.MsOfficeType;
30+
import com.silverpeas.openoffice.util.OsEnum;
31+
import com.silverpeas.openoffice.util.PasswordManager;
32+
import com.silverpeas.openoffice.util.UrlExtractor;
33+
import com.silverpeas.openoffice.windows.MsOfficePathFinder;
2934
import java.io.IOException;
3035
import java.net.MalformedURLException;
3136
import java.net.URL;
3237
import java.util.logging.Level;
3338
import java.util.logging.Logger;
34-
3539
import javax.activation.MimetypesFileTypeMap;
36-
37-
import com.silverpeas.openoffice.util.MsOfficeType;
38-
import com.silverpeas.openoffice.util.OsEnum;
39-
import com.silverpeas.openoffice.util.PasswordManager;
40-
import com.silverpeas.openoffice.util.UrlExtractor;
41-
import com.silverpeas.openoffice.windows.MsOfficePathFinder;
4240
import javax.swing.UIManager;
4341
import javax.swing.UnsupportedLookAndFeelException;
4442

src/main/java/com/silverpeas/openoffice/linux/WhereisHelper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public String findOpenOffice()
6666
if (result == null) {
6767
throw new OpenOfficeNotFoundException();
6868
}
69-
return result.substring(result.indexOf(' ') + 1);
69+
result = result.substring(result.indexOf(' ') + 1);
70+
if(result.contains(" ")) {
71+
result = result.substring(0,result.indexOf(' ') );
72+
}
73+
return result;
7074
}
7175
}
Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
/**
22
* Copyright (C) 2000 - 2009 Silverpeas
33
*
4-
* This program is free software: you can redistribute it and/or modify
5-
* it under the terms of the GNU Affero General Public License as
6-
* published by the Free Software Foundation, either version 3 of the
7-
* License, or (at your option) any later version.
4+
* This program is free software: you can redistribute it and/or modify it under the terms of the
5+
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
6+
* of the License, or (at your option) any later version.
87
*
9-
* As a special exception to the terms and conditions of version 3.0 of
10-
* the GPL, you may redistribute this Program in connection with Free/Libre
11-
* Open Source Software ("FLOSS") applications as described in Silverpeas's
12-
* FLOSS exception. You should have received a copy of the text describing
13-
* the FLOSS exception, and it is also available here:
8+
* As a special exception to the terms and conditions of version 3.0 of the GPL, you may
9+
* redistribute this Program in connection with Free/Libre Open Source Software ("FLOSS")
10+
* applications as described in Silverpeas's FLOSS exception. You should have received a copy of the
11+
* text describing the FLOSS exception, and it is also available here:
1412
* "http://repository.silverpeas.com/legal/licensing"
1513
*
16-
* This program is distributed in the hope that it will be useful,
17-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19-
* GNU Affero General Public License for more details.
14+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
15+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
* Affero General Public License for more details.
2017
*
21-
* You should have received a copy of the GNU Affero General Public License
22-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
* You should have received a copy of the GNU Affero General Public License along with this program.
19+
* If not, see <http://www.gnu.org/licenses/>.
2320
*/
2421

2522
/*
@@ -41,36 +38,45 @@
4138
public class MacOsOfficeFinder implements OfficeFinder {
4239

4340
static final Logger logger = Logger.getLogger(MacOsOfficeFinder.class.getName());
44-
4541
protected static final OpenOfficeFinder finder = new WhereisMacHelper();
46-
protected static final String OFFICE_PATH =
47-
"/Applications/Microsoft Office 2008/";
48-
protected static final String EXCEL_CMD = "open -a \"" + OFFICE_PATH +
49-
"Microsoft Excel.app/Contents/MacOS/Microsoft Excel\"";
50-
protected static final String WORD_CMD = "open -a \"" + OFFICE_PATH +
51-
"Microsoft Word.app/Contents/MacOS/Microsoft Word\"";
52-
protected static final String POWERPOINT_CMD = "open -a \"" + OFFICE_PATH +
53-
"Microsoft PowerPoint.app/Contents/MacOS/Microsoft PowerPoint\"";
42+
protected static final String OFFICE_2008_PATH =
43+
"/Applications/Microsoft Office 2008/";
44+
protected static final String OFFICE_2011_PATH = "/Applications/Microsoft Office 2011/";
45+
protected static final String OFFICE_PATH;
46+
static {
47+
File officeDir = new File(OFFICE_2011_PATH);
48+
if (!officeDir.exists()) {
49+
OFFICE_PATH = OFFICE_2008_PATH;
50+
} else {
51+
OFFICE_PATH = OFFICE_2011_PATH;
52+
}
53+
}
54+
protected static final String EXCEL_CMD = "open -a \"" + OFFICE_PATH
55+
+ "Microsoft Excel.app/Contents/MacOS/Microsoft Excel\"";
56+
protected static final String WORD_CMD = "open -a \"" + OFFICE_PATH
57+
+ "Microsoft Word.app/Contents/MacOS/Microsoft Word\"";
58+
protected static final String POWERPOINT_CMD = "open -a \"" + OFFICE_PATH
59+
+ "Microsoft PowerPoint.app/Contents/MacOS/Microsoft PowerPoint\"";
5460

5561
@Override
5662
public String findSpreadsheet() throws OfficeNotFoundException {
57-
if (isMsOfficePresent()) {
63+
if (isMicrosoftOffice()) {
5864
return EXCEL_CMD;
5965
}
6066
return finder.findSpreadsheet();
6167
}
6268

6369
@Override
6470
public String findPresentation() throws OfficeNotFoundException {
65-
if (isMsOfficePresent()) {
71+
if (isMicrosoftOffice()) {
6672
return POWERPOINT_CMD;
6773
}
6874
return finder.findPresentation();
6975
}
7076

7177
@Override
7278
public String findWordEditor() throws OfficeNotFoundException {
73-
if (isMsOfficePresent()) {
79+
if (isMicrosoftOffice()) {
7480
return WORD_CMD;
7581
}
7682
return finder.findWordEditor();
@@ -87,9 +93,12 @@ public boolean isMicrosoftOffice() {
8793
}
8894

8995
protected boolean isMsOfficePresent() {
90-
File officeDir = new File(OFFICE_PATH);
91-
logger.log(Level.INFO, "Looking for file " + OFFICE_PATH + " but found {0}", officeDir.exists());
96+
File officeDir = new File(OFFICE_2011_PATH);
97+
logger.log(Level.INFO, "Looking for file " + OFFICE_2011_PATH + " but found {0}", officeDir.
98+
exists());
99+
if (!officeDir.exists()) {
100+
officeDir = new File(OFFICE_2008_PATH);
101+
}
92102
return officeDir.exists();
93103
}
94-
95104
}

src/main/java/com/silverpeas/openoffice/util/MessageDisplayer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@ public static void displayError(Throwable t) {
4141
JOptionPane.showMessageDialog(null, t.getMessage(),
4242
MessageUtil.getMessage("error.title"), JOptionPane.ERROR_MESSAGE);
4343
}
44+
45+
public static String displayPromptPassword() {
46+
return JOptionPane.showInputDialog(null, MessageUtil.getMessage("info.missing.password.label"),
47+
MessageUtil.getMessage("info.missing.password.title"), JOptionPane.PLAIN_MESSAGE);
48+
}
4449
}

src/main/java/com/silverpeas/openoffice/util/MessageUtil.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Open Source Software ("FLOSS") applications as described in Silverpeas's
1212
* FLOSS exception. You should have received a copy of the text describing
1313
* the FLOSS exception, and it is also available here:
14-
* "http://repository.silverpeas.com/legal/licensing"
14+
* "http://www.silverpeas.com/legal/licensing"
1515
*
1616
* This program is distributed in the hope that it will be useful,
1717
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,10 +22,6 @@
2222
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2323
*/
2424

25-
/*
26-
* To change this template, choose Tools | Templates
27-
* and open the template in the editor.
28-
*/
2925
package com.silverpeas.openoffice.util;
3026

3127
import java.util.ResourceBundle;

src/main/java/com/silverpeas/openoffice/util/PasswordManager.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Open Source Software ("FLOSS") applications as described in Silverpeas's
1212
* FLOSS exception. You should have received a copy of the text describing
1313
* the FLOSS exception, and it is also available here:
14-
* "http://repository.silverpeas.com/legal/licensing"
14+
* "http://www.silverpeas.com/legal/licensing"
1515
*
1616
* This program is distributed in the hope that it will be useful,
1717
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,10 +22,6 @@
2222
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2323
*/
2424

25-
/*
26-
* To change this template, choose Tools | Templates
27-
* and open the template in the editor.
28-
*/
2925
package com.silverpeas.openoffice.util;
3026

3127
import com.silverpeas.openoffice.AuthenticationInfo;
@@ -97,6 +93,9 @@ public static AuthenticationInfo extractAuthenticationInfo(String login, String
9793
String decodedLogin = login;
9894
try {
9995
clearPwd = decodePassword(encodedPassword);
96+
if(clearPwd.isEmpty()) {
97+
clearPwd = promptForpassword();
98+
}
10099
decodedLogin = URLDecoder.decode(login, "UTF-8");
101100
} catch (Exception e) {
102101
Logger.getLogger(Launcher.class.getName()).log(Level.SEVERE, "can't retrieve credentials", e);
@@ -105,4 +104,8 @@ public static AuthenticationInfo extractAuthenticationInfo(String login, String
105104

106105
return new AuthenticationInfo(decodedLogin, clearPwd);
107106
}
107+
108+
private static String promptForpassword() {
109+
throw new UnsupportedOperationException("Not yet implemented");
110+
}
108111
}

src/main/resources/com/silverpeas/openoffice/messages.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,7 @@ uploading.remote.file=Uploading file: \n
5959

6060
info.user.cancel=The user has stopped the download
6161
upload.file.title=Uploading ...
62-
upload.file.task= Completed %.0f%% of task.\n
62+
upload.file.task= Completed %.0f%% of task.\n
63+
64+
info.missing.password.title=Password required
65+
info.missing.password.label=Please, enter your password

src/main/resources/com/silverpeas/openoffice/messages_en.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,7 @@ upload.file.task= Completed %.0f%% of upload.\n
5757
download.file.title=Downloading ...
5858
downloading.remote.file=Downloading file :
5959
uploading.remote.file=Uploading file :
60-
upload.file.title=Uploding ...
60+
upload.file.title=Uploding ...
61+
62+
info.missing.password.title=Password required
63+
info.missing.password.label=Please, enter your password

src/main/resources/com/silverpeas/openoffice/messages_fr.properties

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,42 @@
2222
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2323
#
2424

25-
info.url.encoded=URL encod\u00E9:
26-
info.url.decoded=URL decod\u00E9:
25+
info.url.encoded=URL encod\u00e9:
26+
info.url.decoded=URL decod\u00e9:
2727
info.document.type=Le document est de type :
2828
info.openoffice.version=OpenOffice version :
2929
info.openoffice.search=Recherche de
30-
info.openoffice.found=trouv\u00E9
30+
info.openoffice.found=trouv\u00e9
3131

3232
info.webdav.locking=Verrouillage du fichier
33-
info.webdav.locked=Fichier verrouill\u00E9
34-
info.webdav.file.locally.saved=Fichier sauvegard\u00E9 localement:
35-
info.webdav.unlocking=D\u00E9verrouillage du fichier
36-
info.webdav.unlocked=Fichier d\u00E9verrouill\u00E9
33+
info.webdav.locked=Fichier verrouill\u00e9
34+
info.webdav.file.locally.saved=Fichier sauvegard\u00e9 localement:
35+
info.webdav.unlocking=D\u00e9verrouillage du fichier
36+
info.webdav.unlocked=Fichier d\u00e9verrouill\u00e9
3737
info.webdav.put=Envoi sur le serveur du fichier :
38-
info.file.updated=Fichier envoy\u00E9
39-
info.file.deleted=Fichier local supprim\u00E9
38+
info.file.updated=Fichier envoy\u00e9
39+
info.file.deleted=Fichier local supprim\u00e9
4040

4141
app.title=Office Launcher
4242
error.title=Erreur
4343
info.title=Information
44-
info.ok=N'oubliez pas de lib\u00E9rer le fichier.
44+
info.ok=N'oubliez pas de lib\u00e9rer le fichier.
4545
info.default.path=Chemin vers Ms Office:
4646
error.message.general=Erreur de lancement MsOffice / OpenOffice
47-
error.decoding.url=Erreur en d\u00E9codant l'URL
47+
error.decoding.url=Erreur en d\u00e9codant l'URL
4848
error.reading.registry=Erreur de lecture de la base de registre Windows
4949
error.webdav.locking=Impossible de verrouiller le fichier distant :
50-
error.webdav.already.locked=Le fichier est d\u00E9ja en cours d'\u00E9dition.\nSi cela n'est pas le cas, veuillez pr\u00E9venir votre Administrateur.
51-
error.get.remote.file=Impossible de r\u00E9cup\u00E9rer le fichier distant :
50+
error.webdav.already.locked=Le fichier est d\u00e9ja en cours d'\u00e9dition.\nSi cela n'est pas le cas, veuillez pr\u00e9venir votre Administrateur.
51+
error.get.remote.file=Impossible de r\u00e9cup\u00e9rer le fichier distant :
5252
error.put.remote.file=Impossible de poser le fichier sur le serveur
5353
error.remote.file=Le fichier distant n'existe plus
54-
error.webdav.unlocking=Impossible de d\u00E9verrouiller le fichier distant :
54+
error.webdav.unlocking=Impossible de d\u00e9verrouiller le fichier distant :
5555

56-
download.file.title=T\u00E9l\u00E9chargement ...
57-
downloading.remote.file=T\u00E9l\u00E9chargement du fichier :
56+
download.file.title=T\u00e9l\u00e9chargement ...
57+
downloading.remote.file=T\u00e9l\u00e9chargement du fichier :
5858
uploading.remote.file=Envoi sur le serveur du fichier :
5959
upload.file.title=Envoi ...
60-
upload.file.task= %.0f%% du fichier envoy\u00E9.
60+
upload.file.task= %.0f%% du fichier envoy\u00e9.
61+
62+
info.missing.password.title=Mot de passe manquant
63+
info.missing.password.label=Entrez votre mot de passe

src/test/java/com/silverpeas/openoffice/linux/WhereisHelperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected void tearDown()
5454
public void testWhereis() {
5555
WhereisHelper helper = getHelper();
5656
String result = helper.whereis();
57-
assertEquals("soffice: /usr/bin/soffice", result);
57+
assertEquals("soffice: /usr/bin/soffice /usr/bin/X11/soffice", result);
5858
}
5959

6060
public void testFindOpenOffice()

src/test/java/com/silverpeas/openoffice/util/PasswordManagerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ public void testDecodePassword() throws Exception {
5858
expResult = "héhèhàhh";
5959
result = PasswordManager.decodePassword(encodedPassword);
6060
assertEquals(expResult, result);
61+
encodedPassword = "c77d90f5ce1e68a2";
62+
expResult = "";
63+
result = PasswordManager.decodePassword(encodedPassword);
64+
assertEquals(expResult, result);
6165
}
66+
67+
6268

6369
/**
6470
* Test of encodePassword method, of class PasswordManager.

0 commit comments

Comments
 (0)