本文整理了Java中org.springframework.security.access.annotation.Secured
类的一些代码示例,展示了Secured
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Secured
类的具体详情如下:
包路径:org.springframework.security.access.annotation.Secured
类名称:Secured
暂无
代码示例来源:origin: spring-projects/spring-security
@Secured("ROLE_A")
void securedMethod();
}
代码示例来源:origin: spring-projects/spring-security
public Collection<ConfigAttribute> extractAttributes(Secured secured) {
String[] attributeTokens = secured.value();
List<ConfigAttribute> attributes = new ArrayList<>(
attributeTokens.length);
for (String token : attributeTokens) {
attributes.add(new SecurityConfig(token));
}
return attributes;
}
}
代码示例来源:origin: codeabovelab/haven-platform
@Secured(Authorities.ADMIN_ROLE)
@RequestMapping(value = "/{cluster}/source", method = POST, consumes = YamlUtils.MIME_TYPE_VALUE)
public UiJob setClusterSource(@PathVariable("cluster") String cluster,
DeployOptions.Builder options,
@RequestBody RootSource rootSource) {
return setRootSrc(cluster, options, rootSource);
}
代码示例来源:origin: pl.edu.icm.synat/synat-console-core
@Secured(ConsoleSecurityRoles.ROLE_PROCESS_ADMIN)
@RequestMapping("/scriptSource/edit")
public String elementEdit(@RequestParam String name, Model model) {
ScriptSource scriptSource = scriptSourceProvider.fetchScriptSource(name);
model.addAttribute("scriptSource", scriptSource);
return "platform/scriptSource/edit";
}
代码示例来源:origin: theotherp/nzbhydra2
@Secured({"ROLE_ADMIN"})
@RequestMapping(value = "/internalapi/migration/url", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public MigrationResult migrateFromUrl(@RequestParam(name = "baseurl") String oldHydraBaseUrl, @RequestParam(name = "doMigrateDatabase") boolean doMigrateDatabase) throws IOException {
messages.clear();
return migration.migrateFromUrl(oldHydraBaseUrl, doMigrateDatabase, true);
}
代码示例来源:origin: theotherp/nzbhydra2
@RequestMapping(value = "/internalapi/nzbzipDownload", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST)
@Secured({"ROLE_USER"})
public FileSystemResource downloadNzbZip(@RequestBody String zipFilepath) {
return new FileSystemResource(zipFilepath);
}
代码示例来源:origin: apache/metron
@Secured({SECURITY_ROLE_PREFIX + SECURITY_ROLE_ADMIN})
@ApiOperation(value = "Deletes a user's settings. Only users that are part of "
+ "the \"ROLE_ADMIN\" role are allowed to delete user settings.")
@ApiResponses(value = {@ApiResponse(message = "User settings were deleted", code = 200),
@ApiResponse(message = "The current user does not have permission to delete user settings",
code = 403),
@ApiResponse(message = "User settings could not be found", code = 404)})
@RequestMapping(value = "/settings/{user}", method = RequestMethod.DELETE)
ResponseEntity<Void> delete(
@ApiParam(name = "user", value = "The user whose settings will be deleted", required = true)
@PathVariable String user)
throws RestException {
if (alertsUIService.deleteAlertsUIUserSettings(user)) {
return new ResponseEntity<>(HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@RequestMapping(value=ViewConstants.OBSERVATION_STOP_OBSERVE_NOTIFICATIONS)
@Secured(PortalUserRoles.USER)
public String stopObserve(Model model, HttpServletRequest request) {
UserProfile userProfile = this.userBusinessService.getCurrentUserProfile();
String userId = userProfile.getId();
if (request.getParameter(UriParamConst.OBSERVATION_SELECTED_CRITERION) != null) {
String[] itemIds = request.getParameterValues(UriParamConst.OBSERVATION_SELECTED_CRITERION);
List<String> criterionIds = rewriteId(itemIds);
int removedCount = criterionIds.size();
observationService.removeCriteria(userId, criterionIds);
notificationService.publishLocalizedNotification(NotificationLevel.INFO, MessageConstants.OBSERVATION_NOTIFICATION_STOP_OBSERVE_SUCCESS, new Object[] {removedCount});
removeNotifications(request, userId);
}
return handleNotifications(model, request);
}
代码示例来源:origin: pl.edu.icm.synat/synat-console-core
@RequestMapping(value = "/scheduler/list", method = RequestMethod.GET)
@Secured(ConsoleSecurityRoles.ROLE_PROCESS_VIEW)
public String listScheduledTasks(Model model) {
model.addAttribute("jobStatuses", schedulerService.listJobs());
return "platform/scheduledTask/definitionsList";
}
代码示例来源:origin: pl.edu.icm.synat/synat-portal-core
@RequestMapping(value=ViewConstants.OBSERVATION_REMOVE_NOTIFICATIONS)
@Secured(PortalUserRoles.USER)
public String removeNotifications(Model model, HttpServletRequest request) {
UserProfile userProfile = this.userBusinessService.getCurrentUserProfile();
String userId = userProfile.getId();
if (Boolean.parseBoolean(request.getParameter(UriParamConst.OBSERVATION_REMOVE_ALL_NOTIFICATIONS))) {
observationService.removeNotifications(userId);
notificationService.publishLocalizedNotification(NotificationLevel.INFO, MessageConstants.SEARCH_HISTORY_REMOVE_ALL_SUCCESS);
} else if (request.getParameter(UriParamConst.OBSERVATION_SELECTED_NOTIFICATION) != null) {
int removedCount = removeNotifications(request, userId);
notificationService.publishLocalizedNotification(NotificationLevel.INFO, MessageConstants.OBSERVATION_NOTIFICATION_REMOVE_SUCCESS, new Object[] {removedCount});
}
return handleNotifications(model, request);
}
代码示例来源:origin: pl.edu.icm.synat/synat-console-core
@RequestMapping(value = "/scheduler/{flowId}", method = RequestMethod.GET)
@Secured(ConsoleSecurityRoles.ROLE_PROCESS_VIEW)
public String showScheduleView(@PathVariable String flowId, Model model) {
model.asMap().putAll(createModelForShowForm(flowId, null));
return "platform/scheduledTask/definitionStart";
}
代码示例来源:origin: apache/metron
@Secured({SECURITY_ROLE_PREFIX + SECURITY_ROLE_ADMIN})
@ApiOperation(value = "Retrieves all users' settings. Only users that are part of "
+ "the \"ROLE_ADMIN\" role are allowed to get all user settings.")
@ApiResponses(value = {@ApiResponse(message = "List of all user settings", code = 200),
@ApiResponse(message =
"The current user does not have permission to get all user settings", code = 403)})
@RequestMapping(value = "/settings/all", method = RequestMethod.GET)
ResponseEntity<Map<String, AlertsUIUserSettings>> findAll() throws RestException {
return new ResponseEntity<>(alertsUIService.findAllAlertsUIUserSettings(), HttpStatus.OK);
}
代码示例来源:origin: pl.edu.icm.synat/synat-console-core
@RequestMapping(value = "/processDefinition/state/{id}", method = RequestMethod.POST)
@ResponseStatus(value=HttpStatus.OK)
@Secured(ConsoleSecurityRoles.ROLE_PROCESS_VIEW)
public void readState(@PathVariable("id") String definitionId, @RequestBody Map<String,String> newState) {
stateHolder.storeTriggerState(definitionId, newState);
}
代码示例来源:origin: pl.edu.icm.synat/synat-console-core
@RequestMapping(value = "/import/{id}", method = RequestMethod.GET)
@Secured(ConsoleSecurityRoles.ROLE_PROCESS_VIEW)
public String importDetails(@PathVariable("id") String id, Model model) {
ImportInfo info = importManager.packInfo(packRepoPath + id);
model.addAttribute("info", info);
return "platform/import/importDetails";
}
代码示例来源:origin: theotherp/nzbhydra2
@Secured({"ROLE_ADMIN"})
@RequestMapping(value = "/internalapi/backup/restorefile", method = RequestMethod.POST)
public GenericResponse restoreFromUpload(@RequestParam("file") MultipartFile file) throws Exception {
return backup.restoreFromFile(file.getInputStream());
}
代码示例来源:origin: theotherp/nzbhydra2
@Secured({"ROLE_STATS"})
@RequestMapping(value = "/internalapi/history/searches", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public Page<SearchEntity> searchHistory(@RequestBody HistoryRequest requestData) {
return history.getHistory(requestData, History.SEARCH_TABLE, SearchEntity.class);
}
代码示例来源:origin: theotherp/nzbhydra2
@RequestMapping(value = "/internalapi/nfo/{guid}", produces = MediaType.APPLICATION_JSON_VALUE)
@Secured({"ROLE_USER"})
public NfoResult getNfo(@PathVariable("guid") long guid) throws IndexerAccessException {
return fileHandler.getNfo(guid);
}
代码示例来源:origin: pl.edu.icm.synat/synat-console-core
@Secured(ConsoleSecurityRoles.ROLE_PROCESS_ADMIN)
@RequestMapping("/scriptSource/add")
public String elementAdd(Model model) {
model.addAttribute("scriptSource", new ScriptSource());
return "platform/scriptSource/add";
}
代码示例来源:origin: pl.edu.icm.synat/synat-console-core
@RequestMapping(value = "/scheduler/processId/{pid}", method = RequestMethod.GET)
@Secured(ConsoleSecurityRoles.ROLE_PROCESS_VIEW)
public String showScheduleViewByProcessId(@PathVariable String pid, Model model) {
ProcessStats processStats = processManager.getProcessStats(pid);
FlowDefinition flowDefinition = processManager.getFlowDefinition(processStats.getFlowId());
Map<String, String> parameters = processStats.getParameters();
model.asMap().putAll(createModelForShowForm(flowDefinition.getFlowId(), parameters));
return "platform/scheduledTask/definitionStart";
}
代码示例来源:origin: apache/metron
@Secured("IS_AUTHENTICATED_FULLY")
@RequestMapping(path = "/whoami/roles", method = RequestMethod.GET)
public List<String> user() {
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().
getAuthentication().getPrincipal();
return userDetails.getAuthorities().stream().map(ga -> ga.getAuthority()).collect(Collectors.toList());
}
}
内容来源于网络,如有侵权,请联系作者删除!