1
|
/**
|
2
|
* Copyright (C) 2014 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.api.application;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.Arrays;
|
14
|
import java.util.HashMap;
|
15
|
import java.util.List;
|
16
|
import java.util.Map;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
import org.springframework.beans.BeansException;
|
20
|
import org.springframework.context.ApplicationContext;
|
21
|
import org.springframework.context.ApplicationContextAware;
|
22
|
import org.springframework.remoting.httpinvoker.CachingHttpInvokerProxyFactoryBean;
|
23
|
import org.springframework.remoting.httpinvoker.HttpComponentsHttpInvokerRequestExecutor;
|
24
|
import org.springframework.security.access.AccessDecisionVoter;
|
25
|
import org.springframework.security.authentication.AuthenticationProvider;
|
26
|
import org.springframework.security.authentication.ProviderManager;
|
27
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
28
|
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
29
|
import org.springframework.security.authentication.dao.ReflectionSaltSource;
|
30
|
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
|
31
|
import org.springframework.security.core.Authentication;
|
32
|
import org.springframework.security.core.context.SecurityContext;
|
33
|
import org.springframework.security.core.context.SecurityContextHolder;
|
34
|
import org.springframework.stereotype.Component;
|
35
|
import org.springframework.transaction.PlatformTransactionManager;
|
36
|
import org.springframework.transaction.TransactionStatus;
|
37
|
|
38
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
39
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
|
40
|
import eu.etaxonomy.cdm.api.service.IAgentService;
|
41
|
import eu.etaxonomy.cdm.api.service.IAnnotationService;
|
42
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
43
|
import eu.etaxonomy.cdm.api.service.ICollectionService;
|
44
|
import eu.etaxonomy.cdm.api.service.ICommonService;
|
45
|
import eu.etaxonomy.cdm.api.service.IDatabaseService;
|
46
|
import eu.etaxonomy.cdm.api.service.IDescriptionService;
|
47
|
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
|
48
|
import eu.etaxonomy.cdm.api.service.IEntityConstraintViolationService;
|
49
|
import eu.etaxonomy.cdm.api.service.IEntityValidationService;
|
50
|
import eu.etaxonomy.cdm.api.service.IEventBaseService;
|
51
|
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
|
52
|
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
|
53
|
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
|
54
|
import eu.etaxonomy.cdm.api.service.IGroupService;
|
55
|
import eu.etaxonomy.cdm.api.service.IIdentificationKeyService;
|
56
|
import eu.etaxonomy.cdm.api.service.ILocationService;
|
57
|
import eu.etaxonomy.cdm.api.service.IMediaService;
|
58
|
import eu.etaxonomy.cdm.api.service.IMetadataService;
|
59
|
import eu.etaxonomy.cdm.api.service.INameService;
|
60
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
61
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
|
62
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
|
63
|
import eu.etaxonomy.cdm.api.service.IPreferenceService;
|
64
|
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
|
65
|
import eu.etaxonomy.cdm.api.service.IReferenceService;
|
66
|
import eu.etaxonomy.cdm.api.service.IRegistrationService;
|
67
|
import eu.etaxonomy.cdm.api.service.IRightsService;
|
68
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
69
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
70
|
import eu.etaxonomy.cdm.api.service.ITermNodeService;
|
71
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
72
|
import eu.etaxonomy.cdm.api.service.ITermTreeService;
|
73
|
import eu.etaxonomy.cdm.api.service.ITestService;
|
74
|
import eu.etaxonomy.cdm.api.service.IUserService;
|
75
|
import eu.etaxonomy.cdm.api.service.IVocabularyService;
|
76
|
import eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService;
|
77
|
import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;
|
78
|
import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
|
79
|
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
|
80
|
import eu.etaxonomy.cdm.ext.geo.IEditGeoService;
|
81
|
import eu.etaxonomy.cdm.io.service.IIOService;
|
82
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionEvaluator;
|
83
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;
|
84
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.UnanimousBasedUnrevokable;
|
85
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionBaseVoter;
|
86
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionElementVoter;
|
87
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.voter.GrantAlwaysVoter;
|
88
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonBaseVoter;
|
89
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonNodeVoter;
|
90
|
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
|
91
|
import eu.etaxonomy.taxeditor.service.AuthenticatingHttpInvokerRequestExecutor;
|
92
|
import eu.etaxonomy.taxeditor.service.CachedCommonServiceImpl;
|
93
|
import eu.etaxonomy.taxeditor.service.ICachedCommonService;
|
94
|
import eu.etaxonomy.taxeditor.service.RemoteInvocationTermCacher;
|
95
|
import eu.etaxonomy.taxeditor.session.CdmEntitySessionManager;
|
96
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
|
97
|
|
98
|
|
99
|
/**
|
100
|
* CDM Application Configuration class which manages the configuration for remoting
|
101
|
* clients
|
102
|
*/
|
103
|
@Component
|
104
|
// TODO split into CdmRepository and proper @Configuration class
|
105
|
public class CdmApplicationRemoteConfiguration implements ICdmRepository, ApplicationContextAware {
|
106
|
|
107
|
@SuppressWarnings("unused")
|
108
|
private static final Logger logger = Logger.getLogger(CdmApplicationRemoteConfiguration.class);
|
109
|
|
110
|
/**
|
111
|
* Timeout for service lookup etc. This timeout (milliseconds) should me more
|
112
|
* strict than {@link #HTTP_READ_TIMEOUT} to avoid connecting to
|
113
|
* cdm servers when the network quality is too bad.
|
114
|
*
|
115
|
*/
|
116
|
public static final int HTTP_READ_TIMEOUT_MIN = 1000; // one second
|
117
|
|
118
|
/**
|
119
|
* Timeout for normal operation (milliseconds)
|
120
|
*
|
121
|
* Infinite time out (value = 0) can cause the application to be stuck in
|
122
|
* SocketInputStream.read(), Therefore it makes sense to specify a definite
|
123
|
* timeout which is high enough to allow for longer operations
|
124
|
* <p>
|
125
|
* The application should be usable in networks with low connection quality,
|
126
|
* e.g.: from cuba where the throughput rate is low (<= ISDN speed, 64 kbit)
|
127
|
* and a packet delay of <200 ms.
|
128
|
*
|
129
|
*/
|
130
|
public static final int HTTP_READ_TIMEOUT = 10 * 60 * 1000;
|
131
|
|
132
|
|
133
|
protected ApplicationContext applicationContext;
|
134
|
|
135
|
private ICdmRemoteSource remoteSource;
|
136
|
|
137
|
//TODO should be something like Map<Class<IService>, IService>, but we have no common service base interface yet
|
138
|
private Map<Class<?>, Object> serviceMap = new HashMap<>();
|
139
|
|
140
|
private ICdmEntitySessionManager cdmEntitySessionManager;
|
141
|
|
142
|
private CdmPermissionEvaluator cdmPermissionEvaluator;
|
143
|
|
144
|
private ProviderManager authenticationManager;
|
145
|
|
146
|
private ICachedCommonService cachedCommonService;
|
147
|
|
148
|
static {
|
149
|
// The Taxeditor is multithreaded, the same authentication should be used
|
150
|
// in all threads
|
151
|
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
|
152
|
}
|
153
|
|
154
|
public CdmApplicationRemoteConfiguration() {}
|
155
|
|
156
|
public CdmApplicationRemoteConfiguration(ICdmRemoteSource remoteSource) {
|
157
|
this.remoteSource = remoteSource;
|
158
|
|
159
|
}
|
160
|
|
161
|
public void setRemoteSource(ICdmRemoteSource remoteSource) {
|
162
|
this.remoteSource = remoteSource;
|
163
|
}
|
164
|
|
165
|
private Object getService(Class<?/* extends IService*/> clazz, String serviceSuffix, HttpComponentsHttpInvokerRequestExecutor executor) {
|
166
|
if(serviceMap.containsKey(clazz)) {
|
167
|
return serviceMap.get(clazz);
|
168
|
}
|
169
|
Object service = getService(clazz, serviceSuffix, remoteSource, executor);
|
170
|
serviceMap.put(clazz, service);
|
171
|
return service;
|
172
|
}
|
173
|
|
174
|
public static Object getService(Class<?> clazz,
|
175
|
String serviceSuffix,
|
176
|
ICdmRemoteSource remoteSource,
|
177
|
HttpComponentsHttpInvokerRequestExecutor executor) {
|
178
|
|
179
|
String baseUrl;
|
180
|
String protocol = remoteSource.getPort() == 443 ? "https" : "http";
|
181
|
if(remoteSource.getContextPath() == null || remoteSource.getContextPath().equals("")) {
|
182
|
baseUrl = protocol + "://" + remoteSource.getServer() + ":" + String.valueOf(remoteSource.getPort());
|
183
|
} else {
|
184
|
baseUrl = protocol + "://" + remoteSource.getServer() + ":" + String.valueOf(remoteSource.getPort()) + "/" + remoteSource.getContextPath();
|
185
|
}
|
186
|
CachingHttpInvokerProxyFactoryBean proxyFactory = new CachingHttpInvokerProxyFactoryBean();
|
187
|
proxyFactory.setServiceInterface(clazz);
|
188
|
proxyFactory.setServiceUrl(baseUrl + serviceSuffix);
|
189
|
if(executor != null) {
|
190
|
executor.setReadTimeout(HTTP_READ_TIMEOUT);
|
191
|
executor.setConnectionRequestTimeout(HTTP_READ_TIMEOUT);
|
192
|
proxyFactory.setHttpInvokerRequestExecutor(executor);
|
193
|
}
|
194
|
if(ITermService.class.isAssignableFrom(clazz)){
|
195
|
proxyFactory.setRemoteInvocationTermCacher(new RemoteInvocationTermCacher());
|
196
|
}
|
197
|
proxyFactory.afterPropertiesSet();
|
198
|
return proxyFactory.getObject();
|
199
|
}
|
200
|
|
201
|
// ****************************** APPLICATION CONTEXT *************************************************/
|
202
|
|
203
|
@Override
|
204
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException{
|
205
|
this.applicationContext = applicationContext;
|
206
|
}
|
207
|
|
208
|
@Override
|
209
|
public PlatformTransactionManager getTransactionManager() throws UnsupportedOperationException {
|
210
|
throw new UnsupportedOperationException("getTransactionManager is not implemented for CdmApplicationRemoteConfiguration");
|
211
|
}
|
212
|
|
213
|
public IEditGeoService getEditGeoService() {
|
214
|
return (IEditGeoService) getService(IEditGeoService.class, "/remoting/editgeo.service", new AuthenticatingHttpInvokerRequestExecutor());
|
215
|
}
|
216
|
|
217
|
public ICachedCommonService getCachedCommonService(){
|
218
|
if(cachedCommonService == null) {
|
219
|
cachedCommonService = new CachedCommonServiceImpl();
|
220
|
}
|
221
|
return cachedCommonService;
|
222
|
}
|
223
|
|
224
|
public ICdmEntitySessionManager getCdmEntitySessionManager() {
|
225
|
if(cdmEntitySessionManager == null) {
|
226
|
cdmEntitySessionManager = new CdmEntitySessionManager();
|
227
|
}
|
228
|
return cdmEntitySessionManager;
|
229
|
}
|
230
|
|
231
|
// ****************************** GETTER *************************************************/
|
232
|
|
233
|
@Override
|
234
|
public final Object getBean(String name){
|
235
|
throw new UnsupportedOperationException("getBean is not implemented for CdmApplicationRemoteConfiguration");
|
236
|
}
|
237
|
|
238
|
@Override
|
239
|
public IAgentService getAgentService(){
|
240
|
return (IAgentService) getService(IAgentService.class, "/remoting/agent.service", new AuthenticatingHttpInvokerRequestExecutor());
|
241
|
}
|
242
|
|
243
|
@Override
|
244
|
public IAnnotationService getAnnotationService(){
|
245
|
return (IAnnotationService) getService(IAnnotationService.class, "/remoting/annotation.service", new AuthenticatingHttpInvokerRequestExecutor());
|
246
|
}
|
247
|
|
248
|
@Override
|
249
|
public IDatabaseService getDatabaseService(){
|
250
|
return (IDatabaseService) getService(IDatabaseService.class, "/remoting/database.service", new AuthenticatingHttpInvokerRequestExecutor());
|
251
|
}
|
252
|
|
253
|
@Override
|
254
|
public INameService getNameService(){
|
255
|
return (INameService) getService(INameService.class, "/remoting/name.service", new AuthenticatingHttpInvokerRequestExecutor());
|
256
|
}
|
257
|
|
258
|
@Override
|
259
|
public IReferenceService getReferenceService(){
|
260
|
return (IReferenceService) getService(IReferenceService.class, "/remoting/reference.service", new AuthenticatingHttpInvokerRequestExecutor());
|
261
|
}
|
262
|
|
263
|
@Override
|
264
|
public ITaxonService getTaxonService(){
|
265
|
return (ITaxonService) getService(ITaxonService.class, "/remoting/taxon.service", new AuthenticatingHttpInvokerRequestExecutor());
|
266
|
}
|
267
|
|
268
|
@Override
|
269
|
public IClassificationService getClassificationService(){
|
270
|
return (IClassificationService) getService(IClassificationService.class, "/remoting/classification.service", new AuthenticatingHttpInvokerRequestExecutor());
|
271
|
}
|
272
|
|
273
|
@Override
|
274
|
public ITaxonNodeService getTaxonNodeService(){
|
275
|
return (ITaxonNodeService) getService(ITaxonNodeService.class, "/remoting/taxonnode.service", new AuthenticatingHttpInvokerRequestExecutor());
|
276
|
}
|
277
|
|
278
|
@Override
|
279
|
public IDescriptionService getDescriptionService(){
|
280
|
return (IDescriptionService) getService(IDescriptionService.class, "/remoting/description.service", new AuthenticatingHttpInvokerRequestExecutor());
|
281
|
}
|
282
|
|
283
|
@Override
|
284
|
public IOccurrenceService getOccurrenceService(){
|
285
|
return (IOccurrenceService) getService(IOccurrenceService.class, "/remoting/occurrence.service", new AuthenticatingHttpInvokerRequestExecutor());
|
286
|
}
|
287
|
|
288
|
@Override
|
289
|
public IPrimerService getPrimerService(){
|
290
|
return (IPrimerService) getService(IPrimerService.class, "/remoting/primer.service", new AuthenticatingHttpInvokerRequestExecutor());
|
291
|
}
|
292
|
|
293
|
@Override
|
294
|
public IAmplificationService getAmplificationService(){
|
295
|
return (IAmplificationService) getService(IAmplificationService.class, "/remoting/amplification.service", new AuthenticatingHttpInvokerRequestExecutor());
|
296
|
}
|
297
|
|
298
|
@Override
|
299
|
public ISequenceService getSequenceService(){
|
300
|
return (ISequenceService) getService(ISequenceService.class, "/remoting/sequence.service", new AuthenticatingHttpInvokerRequestExecutor());
|
301
|
}
|
302
|
|
303
|
@Override
|
304
|
public IEventBaseService getEventBaseService() {
|
305
|
return (IEventBaseService) getService(IEventBaseService.class, "/remoting/eventbase.service", new AuthenticatingHttpInvokerRequestExecutor());
|
306
|
}
|
307
|
|
308
|
@Override
|
309
|
public IMediaService getMediaService(){
|
310
|
return (IMediaService) getService(IMediaService.class, "/remoting/media.service", new AuthenticatingHttpInvokerRequestExecutor());
|
311
|
}
|
312
|
|
313
|
@Override
|
314
|
public ITermService getTermService(){
|
315
|
return (ITermService) getService(ITermService.class, "/remoting/term.service", new AuthenticatingHttpInvokerRequestExecutor());
|
316
|
}
|
317
|
|
318
|
@Override
|
319
|
public IRightsService getRightsService(){
|
320
|
return (IRightsService) getService(IRightsService.class, "/remoting/rights.service", new AuthenticatingHttpInvokerRequestExecutor());
|
321
|
}
|
322
|
|
323
|
@Override
|
324
|
public ICommonService getCommonService(){
|
325
|
return (ICommonService) getService(ICommonService.class, "/remoting/common.service", new AuthenticatingHttpInvokerRequestExecutor());
|
326
|
}
|
327
|
|
328
|
@Override
|
329
|
public ILocationService getLocationService(){
|
330
|
return (ILocationService) getService(ILocationService.class, "/remoting/location.service", new AuthenticatingHttpInvokerRequestExecutor());
|
331
|
}
|
332
|
|
333
|
@Override
|
334
|
public IUserService getUserService(){
|
335
|
return (IUserService) getService(IUserService.class, "/remoting-public/user.service", new AuthenticatingHttpInvokerRequestExecutor());
|
336
|
}
|
337
|
|
338
|
|
339
|
public static IUserService getUserService(ICdmRemoteSource remoteSource) {
|
340
|
return (IUserService) getService(IUserService.class, "/remoting-public/user.service", remoteSource, new HttpComponentsHttpInvokerRequestExecutor());
|
341
|
}
|
342
|
|
343
|
@Override
|
344
|
public IMetadataService getMetadataService() {
|
345
|
return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", new HttpComponentsHttpInvokerRequestExecutor());
|
346
|
}
|
347
|
|
348
|
public static IMetadataService getMetadataService(ICdmRemoteSource remoteSource) {
|
349
|
return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", remoteSource, new HttpComponentsHttpInvokerRequestExecutor());
|
350
|
}
|
351
|
|
352
|
@Override
|
353
|
public IGrantedAuthorityService getGrantedAuthorityService(){
|
354
|
return (IGrantedAuthorityService) getService(IGrantedAuthorityService.class, "/remoting/grantedauthority.service", new AuthenticatingHttpInvokerRequestExecutor());
|
355
|
}
|
356
|
|
357
|
|
358
|
@Override
|
359
|
public ProviderManager getAuthenticationManager(){
|
360
|
if(authenticationManager == null) {
|
361
|
authenticationManager = getAuthenticationManager(getUserService());
|
362
|
}
|
363
|
return authenticationManager;
|
364
|
}
|
365
|
|
366
|
public static ProviderManager getAuthenticationManager(IUserService userService) {
|
367
|
Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();
|
368
|
ReflectionSaltSource saltSource = new ReflectionSaltSource();
|
369
|
saltSource.setUserPropertyToUse("getUsername");
|
370
|
|
371
|
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
|
372
|
daoAuthenticationProvider.setUserDetailsService(userService);
|
373
|
daoAuthenticationProvider.setSaltSource(saltSource);
|
374
|
daoAuthenticationProvider.setPasswordEncoder(passwordEncoder);
|
375
|
|
376
|
return new ProviderManager(Arrays.asList((AuthenticationProvider)daoAuthenticationProvider));
|
377
|
}
|
378
|
|
379
|
|
380
|
@Override
|
381
|
public ConversationHolder NewConversation() {
|
382
|
return new ConversationHolderMock();
|
383
|
}
|
384
|
|
385
|
@Override
|
386
|
public ICollectionService getCollectionService(){
|
387
|
return (ICollectionService) getService(ICollectionService.class, "/remoting/collection.service", new AuthenticatingHttpInvokerRequestExecutor());
|
388
|
}
|
389
|
|
390
|
@Override
|
391
|
public IFeatureTreeService getFeatureTreeService(){
|
392
|
return (IFeatureTreeService) getService(IFeatureTreeService.class, "/remoting/featuretree.service", new AuthenticatingHttpInvokerRequestExecutor());
|
393
|
}
|
394
|
@Override
|
395
|
public ITermTreeService getTermTreeService() {
|
396
|
return (ITermTreeService) getService(ITermTreeService.class, "/remoting/termtree.service", new AuthenticatingHttpInvokerRequestExecutor());
|
397
|
}
|
398
|
|
399
|
@Override
|
400
|
public IFeatureNodeService getFeatureNodeService(){
|
401
|
return (IFeatureNodeService) getService(IFeatureNodeService.class, "/remoting/featurenode.service", new AuthenticatingHttpInvokerRequestExecutor());
|
402
|
}
|
403
|
|
404
|
@Override
|
405
|
public ITermNodeService getTermNodeService() {
|
406
|
return (ITermNodeService) getService(ITermNodeService.class, "/remoting/termnode.service", new AuthenticatingHttpInvokerRequestExecutor());
|
407
|
}
|
408
|
|
409
|
@Override
|
410
|
public IVocabularyService getVocabularyService(){
|
411
|
return (IVocabularyService) getService(IVocabularyService.class, "/remoting/vocabulary.service", new AuthenticatingHttpInvokerRequestExecutor());
|
412
|
}
|
413
|
|
414
|
@Override
|
415
|
public IIdentificationKeyService getIdentificationKeyService(){
|
416
|
return (IIdentificationKeyService) getService(IIdentificationKeyService.class, "/remoting/identificationkey.service", new AuthenticatingHttpInvokerRequestExecutor());
|
417
|
}
|
418
|
|
419
|
@Override
|
420
|
public IPolytomousKeyService getPolytomousKeyService(){
|
421
|
return (IPolytomousKeyService) getService(IPolytomousKeyService.class, "/remoting/polytomouskey.service", new AuthenticatingHttpInvokerRequestExecutor());
|
422
|
}
|
423
|
|
424
|
|
425
|
@Override
|
426
|
public IPolytomousKeyNodeService getPolytomousKeyNodeService(){
|
427
|
return (IPolytomousKeyNodeService) getService(IPolytomousKeyNodeService.class, "/remoting/polytomouskeynode.service", new AuthenticatingHttpInvokerRequestExecutor());
|
428
|
}
|
429
|
|
430
|
@Override
|
431
|
public IProgressMonitorService getProgressMonitorService() {
|
432
|
return (IProgressMonitorService) getService(IProgressMonitorService.class, "/remoting/progressmonitor.service", new AuthenticatingHttpInvokerRequestExecutor());
|
433
|
}
|
434
|
|
435
|
@Override
|
436
|
public IDescriptiveDataSetService getDescriptiveDataSetService(){
|
437
|
return (IDescriptiveDataSetService) getService(IDescriptiveDataSetService.class, "/remoting/descriptivedataset.service", new AuthenticatingHttpInvokerRequestExecutor());
|
438
|
}
|
439
|
|
440
|
@Override
|
441
|
public IRegistrationService getRegistrationService() {
|
442
|
return (IRegistrationService) getService(IRegistrationService.class, "/remoting/registration.service", new AuthenticatingHttpInvokerRequestExecutor());
|
443
|
}
|
444
|
|
445
|
@Override
|
446
|
public IGroupService getGroupService(){
|
447
|
return (IGroupService) getService(IGroupService.class, "/remoting/group.service", new AuthenticatingHttpInvokerRequestExecutor());
|
448
|
}
|
449
|
|
450
|
@Override
|
451
|
public IPreferenceService getPreferenceService(){
|
452
|
return (IPreferenceService) getService(IPreferenceService.class, "/remoting/preference.service", new AuthenticatingHttpInvokerRequestExecutor());
|
453
|
}
|
454
|
|
455
|
@Override
|
456
|
public IEntityValidationService getEntityValidationService(){
|
457
|
return (IEntityValidationService) getService(IEntityValidationService.class, "/remoting/entityvalidation.service", new AuthenticatingHttpInvokerRequestExecutor());
|
458
|
}
|
459
|
|
460
|
@Override
|
461
|
public IEntityConstraintViolationService getEntityConstraintViolationService(){
|
462
|
return (IEntityConstraintViolationService) getService(IEntityConstraintViolationService.class, "/remoting/entityconstraintviolation.service", new AuthenticatingHttpInvokerRequestExecutor());
|
463
|
}
|
464
|
|
465
|
@Override
|
466
|
public ICdmPermissionEvaluator getPermissionEvaluator(){
|
467
|
|
468
|
if(cdmPermissionEvaluator != null) {
|
469
|
return cdmPermissionEvaluator;
|
470
|
}
|
471
|
List<AccessDecisionVoter<? extends Object>> decisionVoters = new ArrayList<>();
|
472
|
decisionVoters.add(new GrantAlwaysVoter());
|
473
|
decisionVoters.add(new TaxonNodeVoter());
|
474
|
decisionVoters.add(new TaxonBaseVoter());
|
475
|
decisionVoters.add(new DescriptionBaseVoter());
|
476
|
decisionVoters.add(new DescriptionElementVoter());
|
477
|
UnanimousBasedUnrevokable accessDecisionManager = new UnanimousBasedUnrevokable(decisionVoters);
|
478
|
|
479
|
cdmPermissionEvaluator = new CdmPermissionEvaluator();
|
480
|
cdmPermissionEvaluator.setAccessDecisionManager(accessDecisionManager);
|
481
|
|
482
|
return cdmPermissionEvaluator;
|
483
|
}
|
484
|
|
485
|
@Override
|
486
|
public TransactionStatus startTransaction() throws UnsupportedOperationException {
|
487
|
throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");
|
488
|
}
|
489
|
|
490
|
@Override
|
491
|
public TransactionStatus startTransaction(Boolean readOnly) throws UnsupportedOperationException {
|
492
|
throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");
|
493
|
}
|
494
|
|
495
|
@Override
|
496
|
public void commitTransaction(TransactionStatus txStatus) throws UnsupportedOperationException {
|
497
|
throw new UnsupportedOperationException("commitTransaction is not implemented for CdmApplicationRemoteConfiguration");
|
498
|
}
|
499
|
|
500
|
@Override
|
501
|
public void rollbackTransaction(TransactionStatus arg0) {
|
502
|
throw new UnsupportedOperationException("rollbackTransaction is not implemented for CdmApplicationRemoteConfiguration");
|
503
|
}
|
504
|
|
505
|
@Override
|
506
|
public void authenticate(String username, String password){
|
507
|
UsernamePasswordAuthenticationToken tokenForUser = new UsernamePasswordAuthenticationToken(username, password);
|
508
|
Authentication authentication = this.getAuthenticationManager().authenticate(tokenForUser);
|
509
|
SecurityContext context = SecurityContextHolder.getContext();
|
510
|
context.setAuthentication(authentication);
|
511
|
}
|
512
|
|
513
|
public IIOService getIOService() {
|
514
|
return (IIOService) getService(IIOService.class, "/remoting/io.service", new AuthenticatingHttpInvokerRequestExecutor());
|
515
|
}
|
516
|
|
517
|
@Override
|
518
|
public ILongRunningTasksService getLongRunningTasksService() {
|
519
|
return (ILongRunningTasksService) getService(ILongRunningTasksService.class, "/remoting/longrunningtasks.service", new AuthenticatingHttpInvokerRequestExecutor());
|
520
|
}
|
521
|
|
522
|
public ITestService getTestService() {
|
523
|
return (ITestService) getService(ITestService.class, "/remoting/test.service", new AuthenticatingHttpInvokerRequestExecutor());
|
524
|
}
|
525
|
}
|