+ static String getFrameworkProp(String key, String def) {
+ String value = Activator.getBundleContext().getProperty(key);
+ if (value == null)
+ return def;
+ return value;
+ }
+
+ static String getFrameworkProp(String key) {
+ return getFrameworkProp(key, null);
+ }
+
+ // Security
+ static Subject anonymousLogin() {
+ Subject subject = new Subject();
+ LoginContext lc;
+ try {
+ lc = new LoginContext(KernelHeader.LOGIN_CONTEXT_ANONYMOUS, subject);
+ lc.login();
+ return subject;
+ } catch (LoginException e) {
+ throw new CmsException("Cannot login as anonymous", e);
+ }
+ }
+
+ // @Deprecated
+ // static void anonymousLogin(AuthenticationManager authenticationManager) {
+ // try {
+ // List<GrantedAuthorityPrincipal> anonAuthorities = Collections
+ // .singletonList(new GrantedAuthorityPrincipal(
+ // KernelHeader.ROLE_ANONYMOUS));
+ // UserDetails anonUser = new User(KernelHeader.USERNAME_ANONYMOUS,
+ // "", true, true, true, true, anonAuthorities);
+ // AnonymousAuthenticationToken anonToken = new
+ // AnonymousAuthenticationToken(
+ // DEFAULT_SECURITY_KEY, anonUser, anonAuthorities);
+ // Authentication authentication = authenticationManager
+ // .authenticate(anonToken);
+ // SecurityContextHolder.getContext()
+ // .setAuthentication(authentication);
+ // } catch (Exception e) {
+ // throw new CmsException("Cannot authenticate", e);
+ // }
+ // }
+