
yakworks.security.shiro.GormShiroRolePermissionResolver.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rally-security Show documentation
Show all versions of rally-security Show documentation
integrates spring security with shiro for rest
/*
* Copyright 2022 Yak.Works - Licensed under the Apache License, Version 2.0 (the "License")
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
package yakworks.security.shiro
import groovy.transform.CompileStatic
import org.apache.shiro.authz.Permission
import org.apache.shiro.authz.permission.RolePermissionResolver
import org.apache.shiro.authz.permission.WildcardPermission
import yakworks.security.gorm.model.SecRolePermission
@CompileStatic
class GormShiroRolePermissionResolver implements RolePermissionResolver {
@Override
Collection resolvePermissionsInRole(String roleString) {
List stringPermissions = SecRolePermission.executeQuery("""
Select sr.permission FROM SecRolePermission sr WHERE upper(sr.role.code) = :roleString
""", [roleString: roleString.toUpperCase()]) as List
List permissions = []
stringPermissions.each { String perm ->
permissions << new WildcardPermission(perm)
}
return permissions
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy