Skip to content

Commit bea9a72

Browse files
committed
deps: removing/replacing esup-commons old library
1 parent 5adde6c commit bea9a72

File tree

8 files changed

+165
-132
lines changed

8 files changed

+165
-132
lines changed

pom.xml

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -143,51 +143,6 @@
143143

144144
<dependencyManagement>
145145
<dependencies>
146-
<dependency>
147-
<groupId>org.esupportail</groupId>
148-
<artifactId>esup-commons2-web</artifactId>
149-
<version>0.2.8</version>
150-
<exclusions>
151-
<exclusion>
152-
<artifactId>
153-
jsr168forwardport.org.springframework.web.portlet
154-
</artifactId>
155-
<groupId>org.springframework</groupId>
156-
</exclusion>
157-
<exclusion>
158-
<artifactId>esup-uportal-ws-client</artifactId>
159-
<groupId>esup</groupId>
160-
</exclusion>
161-
<exclusion>
162-
<artifactId>spring-context-support</artifactId>
163-
<groupId>org.springframework</groupId>
164-
</exclusion>
165-
<exclusion>
166-
<artifactId>spring-beans</artifactId>
167-
<groupId>org.springframework</groupId>
168-
</exclusion>
169-
<exclusion>
170-
<artifactId>slf4j-simple</artifactId>
171-
<groupId>org.slf4j</groupId>
172-
</exclusion>
173-
<exclusion>
174-
<artifactId>spring-test</artifactId>
175-
<groupId>org.springframework</groupId>
176-
</exclusion>
177-
<exclusion>
178-
<artifactId>rome</artifactId>
179-
<groupId>rome</groupId>
180-
</exclusion>
181-
<exclusion>
182-
<artifactId>spring-web</artifactId>
183-
<groupId>org.springframework</groupId>
184-
</exclusion>
185-
<exclusion>
186-
<artifactId>spring-core</artifactId>
187-
<groupId>org.springframework</groupId>
188-
</exclusion>
189-
</exclusions>
190-
</dependency>
191146
<!-- Provides the PortalPropertySourcesPlaceholderConfigurer
192147
that supports global.properties and Jasypt encryption-->
193148
<dependency>
@@ -225,9 +180,11 @@
225180
</dependencyManagement>
226181

227182
<dependencies>
183+
228184
<dependency>
229-
<groupId>org.esupportail</groupId>
230-
<artifactId>esup-commons2-web</artifactId>
185+
<groupId>net.iharder</groupId>
186+
<artifactId>base64</artifactId>
187+
<version>2.3.9</version>
231188
</dependency>
232189

233190
<dependency>

src/main/java/org/esupportail/portlet/filemanager/exceptions/EsupStockException.java

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,40 @@
1717
*/
1818
package org.esupportail.portlet.filemanager.exceptions;
1919

20-
import org.esupportail.commons.exceptions.EsupException;
21-
22-
public class EsupStockException extends EsupException {
23-
24-
protected String codeI18n = "exception.general";
25-
26-
public EsupStockException(Exception e) {
27-
super(e);
28-
}
29-
30-
public EsupStockException(String message) {
31-
super(message);
32-
}
33-
34-
public EsupStockException(String message, String codeI18n) {
35-
super(message);
36-
this.codeI18n = codeI18n;
37-
}
38-
39-
public EsupStockException(String message, Exception e) {
40-
super(message, e);
41-
}
42-
43-
public String getRootCause() {
44-
Throwable t = this;
45-
while(t.getCause() != null)
46-
t = t.getCause();
47-
return t.getMessage();
48-
}
49-
50-
public String getCodeI18n() {
51-
return codeI18n;
52-
}
53-
54-
55-
56-
private static final long serialVersionUID = 1L;
57-
20+
public class EsupStockException extends RuntimeException {
21+
22+
protected String codeI18n = "exception.general";
23+
24+
public EsupStockException(Exception e) {
25+
super(e);
26+
}
27+
28+
public EsupStockException(String message) {
29+
super(message);
30+
}
31+
32+
public EsupStockException(String message, String codeI18n) {
33+
super(message);
34+
this.codeI18n = codeI18n;
35+
}
36+
37+
public EsupStockException(String message, Exception e) {
38+
super(message, e);
39+
}
40+
41+
public String getRootCause() {
42+
Throwable t = this;
43+
while(t.getCause() != null)
44+
t = t.getCause();
45+
return t.getMessage();
46+
}
47+
48+
public String getCodeI18n() {
49+
return codeI18n;
50+
}
51+
52+
53+
54+
private static final long serialVersionUID = 1L;
55+
5856
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package org.esupportail.portlet.filemanager.services.opencmis;
2+
3+
import org.esupportail.portlet.filemanager.exceptions.EsupStockNoRequestBoundException;
4+
import org.springframework.web.context.request.RequestAttributes;
5+
import org.springframework.web.context.request.RequestContextHolder;
6+
import org.springframework.web.context.request.ServletRequestAttributes;
7+
import org.springframework.web.portlet.context.PortletRequestAttributes;
8+
9+
public class ContextUtils {
10+
11+
/**
12+
* @param name
13+
* @return The attribute that corresponds to a name.
14+
*/
15+
public static Object getSessionAttribute(final String name) {
16+
return getContextAttribute(name, RequestAttributes.SCOPE_SESSION);
17+
}
18+
19+
/**
20+
* Set a session attribute.
21+
* @param name
22+
* @param value
23+
*/
24+
public static void setSessionAttribute(
25+
final String name,
26+
final Object value) {
27+
setContextAttribute(name, value, RequestAttributes.SCOPE_SESSION);
28+
}
29+
30+
/**
31+
* @return The request attributes.
32+
* @throws EsupStockNoRequestBoundException
33+
*/
34+
static RequestAttributes getContextAttributes() throws EsupStockNoRequestBoundException {
35+
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
36+
if (requestAttributes == null) {
37+
throw new EsupStockNoRequestBoundException();
38+
}
39+
if (!(requestAttributes instanceof ServletRequestAttributes)
40+
&& !(requestAttributes instanceof PortletRequestAttributes)) {
41+
throw new IllegalArgumentException(
42+
"requestAttributes of unknown class [" + requestAttributes.getClass() + "]");
43+
}
44+
return requestAttributes;
45+
}
46+
47+
/**
48+
* Set an attribute for a given scope.
49+
* @param name
50+
* @param value
51+
* @param scope
52+
*/
53+
private static void setContextAttribute(
54+
final String name,
55+
final Object value,
56+
final int scope) {
57+
getContextAttributes().setAttribute(name, value, scope);
58+
}
59+
60+
/**
61+
* @param name
62+
* @param scope
63+
* @return The value of the attribute for a given scope.
64+
*/
65+
private static Object getContextAttribute(
66+
final String name,
67+
final int scope) {
68+
return getContextAttributes().getAttribute(name, scope);
69+
}
70+
}

src/main/java/org/esupportail/portlet/filemanager/services/opencmis/NuxeoPortalSSOAuthenticationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import java.util.Map;
2727
import java.util.Random;
2828

29+
import net.iharder.Base64;
2930
import org.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider;
30-
import org.esupportail.commons.utils.Base64;
3131

3232
public class NuxeoPortalSSOAuthenticationProvider extends AbstractAuthenticationProvider {
3333

src/main/java/org/esupportail/portlet/filemanager/services/opencmis/TrustedCmisAccessImpl.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,28 @@
2828
import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
2929
import org.apache.commons.logging.Log;
3030
import org.apache.commons.logging.LogFactory;
31-
import org.esupportail.commons.utils.ContextUtils;
3231
import org.esupportail.portlet.filemanager.beans.SharedUserPortletParameters;
3332
import org.esupportail.portlet.filemanager.beans.UserPassword;
3433

3534
public class TrustedCmisAccessImpl extends CmisAccessImpl {
3635

3736
protected static final Log log = LogFactory.getLog(TrustedCmisAccessImpl.class);
38-
37+
3938
protected Map<String, String> userinfosHttpheadersMap;
40-
39+
4140
protected Map<String, String> staticHttpheadersMap;
42-
41+
4342
protected Map<String, String> userinfosHttpheadersValues;
44-
43+
4544
protected String nuxeoPortalSsoSecretKey;
46-
45+
4746
protected String nuxeoPortalSsoUsernameAttribute;
48-
47+
4948
public void setUserinfosHttpheadersMap(
5049
Map<String, String> userinfosHttpheadersMap) {
5150
this.userinfosHttpheadersMap = userinfosHttpheadersMap;
5251
}
53-
52+
5453
public void setStaticHttpheadersMap(Map<String, String> staticHttpheadersMap) {
5554
this.staticHttpheadersMap = staticHttpheadersMap;
5655
}
@@ -67,15 +66,15 @@ public void setNuxeoPortalSsoUsernameAttribute(
6766

6867
@Override
6968
protected void manipulateUri(Map userInfos, String username) {
70-
69+
7170
// useful to test in servlet mode : in userinfosHttpheadersValues we set directly shib attributes values
7271
if(staticHttpheadersMap!=null) {
73-
userinfosHttpheadersValues = new HashMap<String, String>();
72+
userinfosHttpheadersValues = new HashMap<String, String>();
7473
for(String key : staticHttpheadersMap.keySet()) {
7574
userinfosHttpheadersValues.put(key, staticHttpheadersMap.get(key));
7675
}
7776
}
78-
77+
7978
// goal is to get shibboleth attributes from portal via userInfos
8079
if(userinfosHttpheadersMap!=null & userInfos != null) {
8180
userinfosHttpheadersValues = new HashMap<String, String>();
@@ -84,14 +83,14 @@ protected void manipulateUri(Map userInfos, String username) {
8483
userinfosHttpheadersValues.put(key, userInfoValue);
8584
}
8685
}
87-
86+
8887
super.manipulateUri(userInfos, username);
8988
}
9089

91-
90+
9291
@Override
9392
public void open(SharedUserPortletParameters userParameters) {
94-
93+
9594
if(!this.isOpened()) {
9695
manipulateUri(userParameters.getUserInfos(), null);
9796
if(this.userAuthenticatorService != null)
@@ -101,16 +100,16 @@ public void open(SharedUserPortletParameters userParameters) {
101100

102101
parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB
103102
.value());
104-
103+
105104
parameters.put(SessionParameter.ATOMPUB_URL, uri);
106105
parameters.put(SessionParameter.REPOSITORY_ID, respositoryId);
107-
106+
108107
if(userAuthenticatorService != null) {
109108
UserPassword userPassword = userAuthenticatorService.getUserPassword(userParameters);
110109
parameters.put(SessionParameter.USER, userPassword.getUsername());
111110
parameters.put(SessionParameter.PASSWORD, userPassword.getPassword());
112111
}
113-
112+
114113
if(userinfosHttpheadersValues != null) {
115114
parameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, TrustedHttpheadersCmisAuthenticationProvider.class.getName());
116115
Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>();
@@ -120,21 +119,21 @@ public void open(SharedUserPortletParameters userParameters) {
120119
httpHeaders.put(key, values);
121120
}
122121
ContextUtils.setSessionAttribute(TrustedHttpheadersCmisAuthenticationProvider.ESUP_HEADER_SHIB_HTTP_HEADERS, httpHeaders);
123-
}
122+
}
124123
if(nuxeoPortalSsoSecretKey != null && nuxeoPortalSsoUsernameAttribute!=null) {
125-
parameters.put(NuxeoPortalSSOAuthenticationProvider.SECRET_KEY, nuxeoPortalSsoSecretKey);
124+
parameters.put(NuxeoPortalSSOAuthenticationProvider.SECRET_KEY, nuxeoPortalSsoSecretKey);
126125
parameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, NuxeoPortalSSOAuthenticationProvider.class.getName());
127-
126+
128127
String username = (String)userParameters.getUserInfos().get(nuxeoPortalSsoUsernameAttribute);
129128
parameters.put(SessionParameter.USER, username);
130129
}
131-
130+
132131
try {
133-
cmisSession = SessionFactoryImpl.newInstance().createSession(parameters);
132+
cmisSession = SessionFactoryImpl.newInstance().createSession(parameters);
134133
} catch(CmisConnectionException ce) {
135134
log.warn("failed to retriev cmisSession : " + uri + " , repository is not accessible or simply not started ?", ce);
136135
}
137136
}
138137
}
139-
138+
140139
}

src/main/java/org/esupportail/portlet/filemanager/services/opencmis/TrustedHttpheadersCmisAuthenticationProvider.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,23 @@
1717
*/
1818
package org.esupportail.portlet.filemanager.services.opencmis;
1919

20-
import java.util.HashMap;
2120
import java.util.List;
2221
import java.util.Map;
23-
import java.util.Vector;
2422

2523
import org.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider;
26-
import org.apache.chemistry.opencmis.client.bindings.spi.StandardAuthenticationProvider;
2724
import org.apache.commons.logging.Log;
2825
import org.apache.commons.logging.LogFactory;
29-
import org.esupportail.commons.utils.ContextUtils;
30-
import org.springframework.web.context.request.RequestContextHolder;
3126

3227

3328

3429
public class TrustedHttpheadersCmisAuthenticationProvider extends AbstractAuthenticationProvider {
3530

3631
private static final long serialVersionUID = 1L;
37-
32+
3833
protected static final Log log = LogFactory.getLog(TrustedHttpheadersCmisAuthenticationProvider.class);
3934

4035
public static final String ESUP_HEADER_SHIB_HTTP_HEADERS = "ESUP_HEADER_SHIB_HTTP_HEADERS";
41-
36+
4237
@Override
4338
public Map<String, List<String>> getHTTPHeaders(String url) {
4439
Map<String, List<String>> httpHeaders = null;

0 commit comments

Comments
 (0)