Example usage for java.security Principal getName

List of usage examples for java.security Principal getName

Introduction

In this page you can find the example usage for java.security Principal getName.

Prototype

public String getName();

Source Link

Document

Returns the name of this principal.

Usage

From source file:com.epam.ta.reportportal.ws.controller.impl.UserFilterController.java

@Override
@RequestMapping(method = RequestMethod.POST)
@ResponseBody//w  w w .  j a  v  a2s.c o m
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation("Create user filter")
public List<EntryCreatedRS> createFilter(@PathVariable String projectName,
        @RequestBody @Validated CollectionsRQ<CreateUserFilterRQ> createFilterRQ, Principal principal) {
    return createFilterHandler.createFilter(principal.getName(), EntityUtils.normalizeProjectName(projectName),
            createFilterRQ);
}

From source file:org.magnum.mobilecloud.video.AssignmentController.java

@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/unlike", method = RequestMethod.POST)
public @ResponseBody ResponseEntity<Void> unlikeVideo(@PathVariable("id") long id, Principal p) {
    Video video = videos.findOne(id);/*w  w  w  .java  2s  . c  om*/
    if (videos.exists(id)) {
        if (video.userAlreadyLikes(p.getName())) {
            video.removeUserLike(p.getName());
            videos.save(video);
            return new ResponseEntity<Void>(HttpStatus.OK);
        } else {
            return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
        }
    } else {
        return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.epam.ta.reportportal.ws.controller.impl.UserFilterController.java

@Override
@RequestMapping(value = "/shared", method = RequestMethod.GET)
@ResponseBody//w w  w  . ja v  a 2s . co m
@ResponseStatus(HttpStatus.OK)
@ApiOperation("Get all available shared filters (except own shared filters)")
public List<UserFilterResource> getSharedFilters(@PathVariable String projectName,
        @FilterFor(UserFilter.class) Filter filter, Principal principal) {
    return getFilterHandler.getSharedFilters(principal.getName(), filter,
            EntityUtils.normalizeProjectName(projectName));
}

From source file:alfio.controller.api.admin.ConfigurationApiController.java

@RequestMapping(value = "/configuration/events/{eventId}/plugin/load", method = GET)
public List<PluginConfigOption> loadPluginConfiguration(@PathVariable("eventId") int eventId,
        Principal principal) {
    return pluginManager.loadAllConfigOptions(eventId, principal.getName());
}

From source file:alfio.controller.api.admin.ConfigurationApiController.java

@RequestMapping(value = "/configuration/events/{eventId}/load", method = GET)
public Map<ConfigurationKeys.SettingCategory, List<Configuration>> loadEventConfiguration(
        @PathVariable("eventId") int eventId, Principal principal) {
    return configurationManager.loadEventConfig(eventId, principal.getName());
}

From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.organization.GPSecureOrganizationResource.java

@POST
@Path(value = GPServiceRSPathConfig.INSERT_ORGANIZATION_PATH)
@Override/*from ww w .jav  a 2  s .  c o  m*/
public Long insertOrganization(@Auth Principal principal, GPOrganization organization) throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@Executing secure insertOrganization - " + "Principal : {}\n\n",
            principal.getName());
    return super.insertOrganization(organization);
}

From source file:org.magnum.mobilecloud.video.AssignmentController.java

@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/like", method = RequestMethod.POST)
public @ResponseBody ResponseEntity<Void> likeVideo(@PathVariable("id") long id, Principal p) {
    if (videos.exists(id)) {
        Video video = videos.findOne(id);
        if (video.userAlreadyLikes(p.getName())) {
            return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
        } else {/*from w  w  w  .j a v  a  2s . c om*/
            video.addUserLike(p.getName());
            videos.save(video);
            return new ResponseEntity<Void>(HttpStatus.OK);
        }
    } else {
        return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
    }
}

From source file:org.dawnsci.marketplace.controllers.ExtendedRestApiController.java

private boolean canEdit(Principal principal, Long identifier) {
    Account account = accountRepository.findOne(principal.getName());
    Account a = accountRepository.findAccountBySolutionId(identifier);
    if (account.getUsername().equals(a.getUsername())) {
        return true;
    }//  ww w. j a va2  s. c  om
    return false;
}

From source file:com.epam.ta.reportportal.ws.controller.impl.ProjectSettingsController.java

@Override
@RequestMapping(value = "/sub-type", method = RequestMethod.POST)
@ResponseBody//from w w w  .j  ava  2  s .  c o m
@ResponseStatus(CREATED)
@PreAuthorize(PROJECT_LEAD)
@ApiOperation("Creation of custom project specific issue sub-type")
public EntryCreatedRS createProjectIssueSubType(@PathVariable String projectName,
        @RequestBody @Validated CreateIssueSubTypeRQ request, Principal principal) {
    return createSettings.createProjectIssueSubType(EntityUtils.normalizeProjectName(projectName),
            principal.getName(), request);
}

From source file:com.epam.ta.reportportal.ws.controller.impl.ProjectSettingsController.java

@Override
@RequestMapping(value = "/sub-type", method = RequestMethod.PUT)
@ResponseBody/*from  ww  w .  jav  a2s  . co m*/
@ResponseStatus(OK)
@PreAuthorize(PROJECT_LEAD)
@ApiOperation("Update of custom project specific issue sub-type")
public OperationCompletionRS updateProjectIssueSubType(@PathVariable String projectName,
        @RequestBody @Validated UpdateIssueSubTypeRQ request, Principal principal) {
    return updateSettings.updateProjectIssueSubType(EntityUtils.normalizeProjectName(projectName),
            principal.getName(), request);
}