mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2120: Add Java backed webscript to set the security clearance for a specified user
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@103827 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -676,4 +676,11 @@
|
||||
parent="rmBaseWebscript">
|
||||
<property name="securityClearanceService" ref="SecurityClearanceService" />
|
||||
</bean>
|
||||
|
||||
<!-- REST impl for PUT user security clearance -->
|
||||
<bean id="webscript.org.alfresco.rma.classification.usersecurityclearance.put"
|
||||
class="org.alfresco.module.org_alfresco_module_rm.script.classification.UserSecurityClearancePut"
|
||||
parent="rmBaseWebscript">
|
||||
<property name="securityClearanceService" ref="SecurityClearanceService"/>
|
||||
</bean>
|
||||
</beans>
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>Users security clearance</shortname>
|
||||
<description>REST API to set users security clearance</description>
|
||||
<url>/api/classification/clearance?username={username}&clearanceId={clearanceId}</url>
|
||||
<format default="json">argument</format>
|
||||
<authentication>admin</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1,7 @@
|
||||
<#import "usersecurityclearance.lib.ftl" as usersecurityclearance />
|
||||
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
"data": <@usersecurityclearance.usersecurityclearanceJSON item=item />
|
||||
}
|
||||
</#escape>
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.script.classification;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearance;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Implementation for Java backed webscript to set users security clearance.
|
||||
*
|
||||
* @author David Webster
|
||||
* @author Tom Page
|
||||
* @since 3.0
|
||||
*/
|
||||
public class UserSecurityClearancePut extends AbstractRmWebScript
|
||||
{
|
||||
/** Constants */
|
||||
private static final String USERNAME = "username";
|
||||
private static final String CLEARANCE_ID = "clearanceId";
|
||||
private static final String ITEM = "item";
|
||||
|
||||
/** Security clearance service */
|
||||
private SecurityClearanceService securityClearanceService;
|
||||
|
||||
/**
|
||||
* @param securityClearanceService the securityClearanceService to set
|
||||
*/
|
||||
public void setSecurityClearanceService(SecurityClearanceService securityClearanceService)
|
||||
{
|
||||
this.securityClearanceService = securityClearanceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
|
||||
* org.springframework.extensions.webscripts.Status,
|
||||
* org.springframework.extensions.webscripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
String username = req.getParameter(USERNAME);
|
||||
String clearanceId = req.getParameter(CLEARANCE_ID);
|
||||
|
||||
SecurityClearance securityClearance = securityClearanceService.setUserSecurityClearance(username, clearanceId);
|
||||
|
||||
Map<String, Object> model = new HashMap<>();
|
||||
model.put(ITEM, securityClearance);
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user