Permalink
Browse files

Moving some services to cinnamon main.

  • Loading branch information...
dewarim committed Apr 26, 2012
1 parent d694019 commit b91d3c62b8cb59b41b1eb3f3feceed2048e9a7a5
Showing with 112 additions and 2,250 deletions.
  1. +2 −2 CinnamonDbGrailsPlugin.groovy
  2. +11 −0 README
  3. +2 −2 cinnamonBase.iml
  4. +1 −0 grails-app/conf/BuildConfig.groovy
  5. +0 −143 grails-app/controllers/cinnamon/LoginController.groovy
  6. +0 −24 grails-app/controllers/cinnamon/LogoutController.groovy
  7. +3 −3 grails-app/domain/cinnamon/Folder.groovy
  8. +3 −2 grails-app/domain/cinnamon/ObjectSystemData.groovy
  9. +0 −122 grails-app/services/cinnamon/CinnamonUserDetailsService.groovy
  10. +0 −235 grails-app/services/cinnamon/FolderService.groovy
  11. +0 −103 grails-app/services/cinnamon/InputValidationService.groovy
  12. +0 −22 grails-app/services/cinnamon/LanguageService.groovy
  13. +0 −9 grails-app/services/cinnamon/LuceneService.groovy
  14. +1 −2 grails-app/services/cinnamon/MetasetService.groovy
  15. +0 −17 grails-app/services/cinnamon/ObjectTypeService.groovy
  16. +0 −208 grails-app/services/cinnamon/OsdService.groovy
  17. +0 −13 grails-app/services/cinnamon/PermissionService.groovy
  18. +0 −30 grails-app/services/cinnamon/RelationService.groovy
  19. +0 −298 grails-app/services/cinnamon/RepositoryService.groovy
  20. +0 −45 grails-app/services/cinnamon/SessionService.groovy
  21. +0 −11 grails-app/services/cinnamon/UserGroupService.groovy
  22. +0 −237 grails-app/services/cinnamon/UserService.groovy
  23. +0 −159 grails-app/views/login/auth.gsp
  24. +0 −16 grails-app/views/login/denied.gsp
  25. +0 −5 grails-app/views/login/dummyPage.gsp
  26. +0 −37 grails-app/views/logout/info.gsp
  27. +0 −132 grails-app/views/shared/_ajax_auth.gsp
  28. +0 −5 grails-app/views/shared/_errors.gsp
  29. +0 −9 grails-app/views/shared/_footer.gsp
  30. +0 −21 grails-app/views/shared/_header.gsp
  31. +0 −6 grails-app/views/shared/_infoMessage.gsp
  32. +0 −3 grails-app/views/shared/_logo.gsp
  33. +0 −3 grails-app/views/shared/_logo_big.gsp
  34. +0 −3 grails-app/views/shared/_message.gsp
  35. +0 −3 grails-app/views/shared/_showError.gsp
  36. +0 −45 src/groovy/humulus/CinnamonPasswordEncoder.groovy
  37. +0 −65 src/groovy/humulus/Environment.groovy
  38. +0 −20 src/groovy/humulus/EnvironmentHolder.groovy
  39. +0 −129 src/groovy/humulus/RepositoryLoginFilter.groovy
  40. +0 −50 src/groovy/humulus/SwitchableDataSource.groovy
  41. +2 −1 src/java/cinnamon/interfaces/IMetasetOwner.java
  42. +2 −1 src/java/cinnamon/interfaces/XmlConvertable.java
  43. +17 −0 test/unit/cinnamon/FolderMetasetTests.groovy
  44. +0 −1 test/unit/cinnamon/FolderServiceTests.groovy
  45. +0 −1 test/unit/cinnamon/LanguageServiceTests.groovy
  46. +0 −1 test/unit/cinnamon/LuceneServiceTests.groovy
  47. +16 −0 test/unit/cinnamon/MetasetServiceTests.groovy
  48. +17 −0 test/unit/cinnamon/MetasetTests.groovy
  49. +17 −0 test/unit/cinnamon/MetasetTypeTests.groovy
  50. +0 −1 test/unit/cinnamon/ObjectTypeServiceTests.groovy
  51. +17 −0 test/unit/cinnamon/OsdMetasetTests.groovy
  52. +0 −1 test/unit/cinnamon/OsdServiceTests.groovy
  53. +0 −1 test/unit/cinnamon/PermissionServiceTests.groovy
  54. +0 −1 test/unit/cinnamon/RelationServiceTests.groovy
  55. +0 −1 test/unit/cinnamon/SessionServiceTests.groovy
  56. +1 −1 tmp/resources.groovy
@@ -1,9 +1,9 @@
class CinnamonDbGrailsPlugin {
- def packaging = "binary"
+// def packaging = "binary"
def groupId = 'cinnamon'
// the plugin version
- def version = "0.1.4"
+ def version = "0.1.11"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "2.0 > *"
// the other plugins this plugin depends on
View
11 README
@@ -0,0 +1,11 @@
+Grails plugin: cinnamon-db
+
+This plugin contains the database classes as well as other essentials for the Cinnamon CMS (http://cinnamon-cms.de)
+
+Note: this repository contains code for an new release (Cinnamon 3) which will be heavily refactored since we are
+trying to convert from a split application (Java Server with custom Servlet code, accessed by desktop and Grails
+applications for the webclient and the administration interface) to a more unified server using the Grails framework.
+
+The Cinnamon CMS version 2 is stable and in production use, the project home is: http://sourceforge.net/projects/cinnamon
+The development version 3 here is still in its early stages and subject to change.
+
View
@@ -33,13 +33,13 @@
<sourceFolder url="file://$MODULE_DIR$/grails-app/utils" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/groovy" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/grails-app/i18n" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/grails-app/controllers" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/grails-app/domain" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/grails-app/services" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/grails-app/taglib" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test/unit" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/test/integration" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/grails-app/conf" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/grails-app/services" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/grails-app/controllers" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target/classes" />
</content>
<orderEntry type="inheritedJdk" />
@@ -1,3 +1,4 @@
+
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
@@ -1,143 +0,0 @@
-package cinnamon
-
-import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
-
-import grails.converters.JSON
-import org.springframework.security.authentication.AccountExpiredException
-import org.springframework.security.authentication.CredentialsExpiredException
-import org.springframework.security.authentication.DisabledException
-import org.springframework.security.authentication.LockedException
-import org.springframework.security.core.context.SecurityContextHolder
-import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
-import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
-
-class LoginController {
-
- /**
- * Dependency injection for the authenticationTrustResolver.
- */
- def authenticationTrustResolver
-
- /**
- * Dependency injection for the springSecurityService.
- */
- def springSecurityService
-
- /**
- * Default action; redirects to 'defaultTargetUrl' if logged in, /login/auth otherwise.
- */
- def index = {
- if (springSecurityService.isLoggedIn()) {
- redirect uri: SpringSecurityUtils.securityConfig.successHandler.defaultTargetUrl
- }
- else {
- redirect action: auth, params: params
- }
- }
-
- /**
- * Show the login page.
- */
- def auth = {
-
- def config = SpringSecurityUtils.securityConfig
-
- if (springSecurityService.isLoggedIn()) {
- log.debug("user is logged in, redirecting")
- redirect uri: config.successHandler.defaultTargetUrl
- return
- }
- if(params.logoutMessage){
- flash.message = message(code:params.logoutMessage.encodeAsHTML())
- }
- String postUrl = "${request.contextPath}${config.apf.filterProcessesUrl}"
- return [postUrl: postUrl,
- rememberMeParameter: config.rememberMe.parameter,
- repositories: Environment.list()
- ]
- }
-
- /**
- * Show denied page.
- */
- def denied = {
- if (springSecurityService.isLoggedIn() &&
- authenticationTrustResolver.isRememberMe(SecurityContextHolder.context?.authentication)) {
- // have cookie but the page is guarded with IS_AUTHENTICATED_FULLY
- redirect action: full, params: params
- }
- }
-
- /**
- * Login page for users with a remember-me cookie but accessing a IS_AUTHENTICATED_FULLY page.
- */
- def full = {
- def config = SpringSecurityUtils.securityConfig
- render view: 'auth', params: params,
- model: [hasCookie: authenticationTrustResolver.isRememberMe(SecurityContextHolder.context?.authentication),
- postUrl: "${request.contextPath}${config.apf.filterProcessesUrl}"]
- }
-
- /**
- * Callback after a failed login. Redirects to the auth page with a warning message.
- */
- def authfail = {
-
- def username = session[UsernamePasswordAuthenticationFilter.SPRING_SECURITY_LAST_USERNAME_KEY]
- String msg = ''
- def exception = session[AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY]
- if (exception) {
- if (exception instanceof AccountExpiredException) {
- msg = SpringSecurityUtils.securityConfig.errors.login.expired
- }
- else if (exception instanceof CredentialsExpiredException) {
- msg = SpringSecurityUtils.securityConfig.errors.login.passwordExpired
- }
- else if (exception instanceof DisabledException) {
- msg = SpringSecurityUtils.securityConfig.errors.login.disabled
- }
- else if (exception instanceof LockedException) {
- msg = SpringSecurityUtils.securityConfig.errors.login.locked
- }
- else {
- msg = SpringSecurityUtils.securityConfig.errors.login.fail
- }
- }
-
- if (springSecurityService.isAjax(request)) {
- render([error: msg] as JSON)
- }
- else {
- flash.message = msg
- redirect action: auth, params: params
- }
- }
-
- /**
- * The Ajax success redirect url.
- */
- def ajaxSuccess = {
- render([success: true, username: springSecurityService.authentication.name] as JSON)
- }
-
- /**
- * The Ajax denied redirect url.
- */
- def ajaxDenied = {
- render(status:503, text:message(code:'error.access.denied'))
- }
-
- def ajaxAuth = {
- log.debug("ajaxAuth called")
- render(status:401, template:'/shared/ajax_auth', model:[environment:params.envId])
- }
-
- def authAjax= {
- log.debug("authAjax called")
- render(status:401, template:'/shared/ajax_auth', model:[environment:params.envId])
- }
-
- def dummyPage = {
-
- }
-}
@@ -1,24 +0,0 @@
-package cinnamon
-
-import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
-
-class LogoutController {
-
- def repositoryService
- def userService
-
- /**
- * Index action. Redirects to the Spring security logout uri.
- */
- def index = {
- // TODO put any pre-logout code here
- UserAccount user = userService.user
- repositoryService.removeUserFromCache(user, session.repositoryName)
-
- redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl // '/j_spring_security_logout'
- }
-
- def info = {
- return [logoutMessage:params.logoutMessage?.encodeAsHTML()]
- }
-}
@@ -17,8 +17,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
import cinnamon.exceptions.CinnamonConfigurationException
import cinnamon.interfaces.IMetasetOwner
import org.dom4j.Node
-import javax.persistence.EntityManager
-import javax.persistence.Query
+
import cinnamon.interfaces.IMetasetJoin
class Folder implements Ownable, Indexable, XmlConvertable, Serializable, IMetasetOwner {
@@ -560,7 +559,7 @@ class Folder implements Ownable, Indexable, XmlConvertable, Serializable, IMetas
*/
public String getMetadata() {
// for compatibility: return non-empty metadata, otherwise try to compile metasets
- if(metadata.length() > 8 && getFolderMetasets().size() == 0){
+ if(metadata.length() > 8 && metasets.size() == 0){
return metadata;
}
Document doc = DocumentHelper.createDocument();
@@ -665,4 +664,5 @@ class Folder implements Ownable, Indexable, XmlConvertable, Serializable, IMetas
om.save()
}
+ Long myId() { return id }
}
@@ -10,15 +10,15 @@ import cinnamon.exceptions.CinnamonException
import cinnamon.utils.ParamParser
import org.dom4j.Document
import org.dom4j.DocumentHelper
-import javax.persistence.EntityManager
+
import org.dom4j.Element
import cinnamon.global.Conf
import cinnamon.global.ConfThreadLocal
import cinnamon.utils.FileKeeper
import javax.persistence.NoResultException
import cinnamon.utils.ContentReader
import org.dom4j.Node
-import javax.persistence.Query
+
import cinnamon.interfaces.IMetasetJoin
import cinnamon.exceptions.CinnamonConfigurationException
import cinnamon.interfaces.IMetasetOwner
@@ -904,4 +904,5 @@ class ObjectSystemData implements Serializable, Ownable, Indexable, XmlConverta
return metaset;
}
+ Long myId() { return id }
}
@@ -1,122 +0,0 @@
-package cinnamon
-
-import org.springframework.security.core.GrantedAuthority
-import org.springframework.security.core.authority.GrantedAuthorityImpl
-
-import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils
-import org.codehaus.groovy.grails.plugins.springsecurity.GormUserDetailsService
-import org.springframework.security.core.userdetails.UsernameNotFoundException
-import org.springframework.security.core.userdetails.UserDetails
-import org.codehaus.groovy.grails.plugins.springsecurity.GrailsUser
-
-import org.codehaus.groovy.grails.plugins.springsecurity.GrailsUserDetailsService
-
-import org.codehaus.groovy.grails.plugins.springsecurity.SecurityRequestHolder as SRH
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-import org.codehaus.groovy.grails.plugins.springsecurity.SecurityRequestHolder
-import humulus.EnvironmentHolder
-
-/*
- This class is based upon UserDetailsService from the Grails security plugin.
- */
-class CinnamonUserDetailsService implements GrailsUserDetailsService{
-
- /*
- Note: this service must be injected in spring/resources,
- it will not be automatically injected.
- */
- def repositoryService
-
- private Logger log = LoggerFactory.getLogger(this.class)
-
- /**
- * Some Spring Security classes (e.g. RoleHierarchyVoter) expect at least one role, so
- * we give a user with no granted roles this one which gets past that restriction but
- * doesn't grant anything.
- */
- static final List NO_ROLES = [new GrantedAuthorityImpl(SpringSecurityUtils.NO_ROLE)]
-
- /**
- * {@inheritDoc}
- * @see org.codehaus.groovy.grails.plugins.springsecurity.GrailsUserDetailsService #loadUserByUsername(
- * java.lang.String, boolean)
- */
- UserDetails loadUserByUsername(String username, boolean loadRoles) throws UsernameNotFoundException {
- log.debug("username:$username")
- loadUser(username, loadRoles)
- }
-
- /**
- * {@inheritDoc}
- * @see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)
- */
- UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
- log.debug("username:$username")
- loadUserByUsername username, true
- }
-
- protected UserDetails loadUser(String username, boolean loadRoles) {
-// HttpServletRequest request = SecurityRequestHolder.getRequest()
-// def params = request.parameterMap
-
- def user = loadUser(username)
- Collection<GrantedAuthority> authorities = loadAuthorities(user, loadRoles)
- createUserDetails user, authorities
- }
-
- protected loadUser(String username) {
- UserAccount user = UserAccount.findByName(username)
-
- if (!user) {
- log.warn "UserAccount not found: $username"
-// log.warn("UserAccount list:")
-// log.warn "${UserAccount.list()}"
- throw new UsernameNotFoundException('UserAccount not found', username)
- }
- else{
- log.debug("found user : $user")
- }
-
- return user
- }
-
- protected UserDetails createUserDetails(user, Collection<GrantedAuthority> authorities) {
- log.debug("create user details")
- String username = user.name
- String password = user.pwd
-
- // create a client which accesses Cinnamon over the official API.
- def env = EnvironmentHolder.getEnvironment()
- String repositoryName = env?.dbname
- String url = env?.cinnamonServerUrl
-
- // gain access to unencrypted password which we need to login remotely to the server:
- def params = SecurityRequestHolder.request.parameterMap
-// Client client = new Client(url, username, (String) params.get('j_password')[0], repositoryName)
-// repositoryService.addClient(client)
-
- boolean enabled = user.activated
- boolean accountExpired = user.accountExpired
- boolean accountLocked = user.accountLocked
- boolean passwordExpired = user.passwordExpired
-
- new GrailsUser(username, password, enabled, !accountExpired, !passwordExpired,
- !accountLocked, authorities, user.id)
- }
-
- protected Collection<GrantedAuthority> loadAuthorities(UserAccount user, boolean loadRoles) {
- if (!loadRoles) {
- log.debug("do not load roles")
- return []
- }
- log.debug("loading roles / groups")
- Collection<CmnGroupUser> gusers = CmnGroupUser.findAllByUser(user)
- def authorities = gusers.collect {
- new GrantedAuthorityImpl(it.group.name)
- }
- return authorities ?: NO_ROLES
- }
-
-}
Oops, something went wrong.

0 comments on commit b91d3c6

Please sign in to comment.