Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
bf7d1a68
Commit
bf7d1a68
authored
Oct 27, 2017
by
Maxym Borodenko
Committed by
Matija Obreza
Oct 30, 2017
Browse files
OAuthClient as ACL SID
- updated permission editor
parent
da73a733
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/servlet/controller/JspHelper.java
View file @
bf7d1a68
...
...
@@ -25,6 +25,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.math.RandomUtils
;
import
org.genesys.blocks.oauth.model.OAuthClient
;
import
org.genesys.blocks.oauth.service.OAuthClientDetailsService
;
import
org.genesys.blocks.security.UserException
;
import
org.genesys2.server.model.impl.Country
;
import
org.genesys2.server.model.impl.Crop
;
import
org.genesys2.server.model.impl.User
;
...
...
@@ -57,6 +60,9 @@ public class JspHelper {
@Autowired
private
HtmlConverter
htmlConverter
;
@Autowired
private
OAuthClientDetailsService
clientDetailsService
;
public
String
userFullName
(
Long
userId
)
{
if
(
userId
==
null
)
{
return
null
;
...
...
@@ -77,6 +83,13 @@ public class JspHelper {
return
userService
.
getUserByUuid
(
uuid
);
}
public
OAuthClient
getByClientId
(
final
String
clientId
)
{
if
(
clientId
==
null
)
{
return
null
;
}
return
clientDetailsService
.
getClient
(
clientId
);
}
public
Country
getCountry
(
String
iso3
)
{
return
geoService
.
getCountry
(
iso3
);
}
...
...
src/main/java/org/genesys2/server/servlet/controller/rest/PermissionController.java
View file @
bf7d1a68
...
...
@@ -17,9 +17,12 @@
package
org.genesys2.server.servlet.controller.rest
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.genesys.blocks.oauth.model.OAuthClient
;
import
org.genesys.blocks.oauth.service.OAuthClientDetailsService
;
import
org.genesys.blocks.security.model.AclObjectIdentity
;
import
org.genesys.blocks.security.service.CustomAclService
;
import
org.genesys2.server.model.impl.User
;
...
...
@@ -47,20 +50,16 @@ public class PermissionController extends RestController {
@Autowired
private
UserService
userService
;
@Autowired
private
OAuthClientDetailsService
clientDetailsService
;
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
@ResponseBody
Object
addPermission
(
@RequestBody
PermissionJson
permissionJson
)
{
LOG
.
info
(
"Adding permission {}"
,
permissionJson
);
final
Map
<
Integer
,
Boolean
>
permissionMap
=
PermissionJsonUtil
.
createPermissionsMap
(
permissionJson
);
if
(
permissionJson
.
isPrincipal
())
{
final
User
user
=
userService
.
getUserByEmail
(
permissionJson
.
getUuid
());
aclService
.
addPermissions
(
permissionJson
.
getOid
(),
permissionJson
.
getClazz
(),
user
.
getUuid
(),
permissionJson
.
isPrincipal
(),
permissionMap
);
return
JSON_OK
;
}
else
{
aclService
.
addPermissions
(
permissionJson
.
getOid
(),
permissionJson
.
getClazz
(),
permissionJson
.
getUuid
(),
permissionJson
.
isPrincipal
(),
permissionMap
);
return
JSON_OK
;
}
aclService
.
addPermissions
(
permissionJson
.
getOid
(),
permissionJson
.
getClazz
(),
permissionJson
.
getUuid
(),
permissionJson
.
isPrincipal
(),
permissionMap
);
return
JSON_OK
;
}
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
...
...
@@ -81,4 +80,13 @@ public class PermissionController extends RestController {
}
return
userEmails
;
}
@RequestMapping
(
value
=
"/autocomplete-oauth-client"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
@ResponseBody
Map
<
String
,
String
>
acOauthClient
(
@RequestParam
(
"term"
)
String
title
)
{
final
Map
<
String
,
String
>
oauthMap
=
new
HashMap
<>();
for
(
final
OAuthClient
client
:
clientDetailsService
.
autocompleteClients
(
title
))
{
oauthMap
.
put
(
client
.
getTitle
(),
client
.
getClientId
());
}
return
oauthMap
;
}
}
src/main/webapp/WEB-INF/jsp/acl/editor.jsp
View file @
bf7d1a68
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment