Revision 40a41f9f
Added by Andreas Müller almost 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java | ||
---|---|---|
17 | 17 |
import org.slf4j.Marker; |
18 | 18 |
import org.springframework.core.io.ClassPathResource; |
19 | 19 |
import org.springframework.core.io.Resource; |
20 |
import org.springframework.security.access.PermissionEvaluator; |
|
21 | 20 |
import org.springframework.security.authentication.AuthenticationManager; |
22 | 21 |
import org.springframework.security.core.Authentication; |
23 | 22 |
import org.springframework.security.core.GrantedAuthority; |
... | ... | |
113 | 112 |
* |
114 | 113 |
* @author n.hoffmann |
115 | 114 |
* @created 17.03.2009 |
116 |
* @version 1.0 |
|
117 | 115 |
*/ |
118 | 116 |
public class CdmStore { |
119 | 117 |
|
120 | 118 |
private static final Resource DEFAULT_APPLICATION_CONTEXT = new ClassPathResource( |
121 | 119 |
"/eu/etaxonomy/cdm/editorApplicationContext.xml", |
122 | 120 |
TaxeditorStorePlugin.class); |
121 |
|
|
123 | 122 |
private static final DbSchemaValidation DEFAULT_DB_SCHEMA_VALIDATION = DbSchemaValidation.VALIDATE; |
124 | 123 |
|
125 | 124 |
private static CdmStore instance; |
... | ... | |
151 | 150 |
|
152 | 151 |
|
153 | 152 |
/** |
154 |
* <p> |
|
155 |
* getDefault |
|
156 |
* </p> |
|
157 |
* |
|
158 | 153 |
* @return a {@link eu.etaxonomy.taxeditor.store.CdmStore} object. |
159 | 154 |
*/ |
160 | 155 |
protected static CdmStore getDefault(boolean connecting){ |
... | ... | |
166 | 161 |
}else{ |
167 | 162 |
MessagingUtils.noDataSourceWarningDialog(instance); |
168 | 163 |
} |
169 |
|
|
170 |
|
|
171 | 164 |
return null; |
172 | 165 |
} |
173 | 166 |
} |
167 |
|
|
174 | 168 |
/** |
175 | 169 |
* <p> |
176 | 170 |
* getDefault |
... | ... | |
423 | 417 |
*/ |
424 | 418 |
public static ICommonService getCommonService() { |
425 | 419 |
return CdmApplicationState.getCommonService(); |
426 |
|
|
427 | 420 |
} |
428 | 421 |
|
429 |
/** |
|
430 |
* <p> |
|
431 |
* getAuthenticationManager |
|
432 |
* </p> |
|
433 |
* |
|
434 |
* @return a |
|
435 |
* {@link org.springframework.security.authentication.ProviderManager} |
|
436 |
* object. |
|
437 |
*/ |
|
438 | 422 |
public static AuthenticationManager getAuthenticationManager() { |
439 | 423 |
return getCurrentApplicationConfiguration().getAuthenticationManager(); |
440 | 424 |
} |
441 | 425 |
|
442 |
/** |
|
443 |
* <p> |
|
444 |
* getAuthenticationManager |
|
445 |
* </p> |
|
446 |
* |
|
447 |
* @return a |
|
448 |
* {@link ICdmPermissionEvaluator} object. |
|
449 |
*/ |
|
450 | 426 |
public static ICdmPermissionEvaluator getPermissionEvaluator() { |
451 | 427 |
return getCurrentApplicationConfiguration().getPermissionEvaluator(); |
452 | 428 |
} |
... | ... | |
466 | 442 |
public static boolean currentAuthentiationHasPermission(CdmBase targetDomainObject, EnumSet<CRUD> permission){ |
467 | 443 |
//TODO use getCurrentApplicationConfiguration().currentAuthentiationHasPermission(CdmBase targetDomainObject, Operation permission) instead |
468 | 444 |
SecurityContext context = SecurityContextHolder.getContext(); |
469 |
PermissionEvaluator pe = getPermissionEvaluator(); |
|
470 | 445 |
boolean hasPermission = false; |
471 | 446 |
try { |
472 | 447 |
hasPermission = getPermissionEvaluator().hasPermission(context.getAuthentication(), targetDomainObject, |
... | ... | |
656 | 631 |
} |
657 | 632 |
|
658 | 633 |
|
634 |
@SuppressWarnings("unchecked") |
|
659 | 635 |
public static <T extends CdmBase> IService<T> getService(T cdmBase){ |
660 | 636 |
IService<T> service = null; |
661 | 637 |
if(cdmBase!=null){ |
Also available in: Unified diff
cleanup