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:pdl.web.controller.rest.RestMainController.java

/**
 * update file record as file operation finishes
 * @return file information (UUID, absolute path) in json format
 * @format curl <ip address>:<port>/pdl/r/file/commit/?id=<file id> -u <user id>:<pass> -X POST|GET
 *///  ww w  . ja  v a 2 s  .  c  o  m
@RequestMapping(value = "file/commit", method = { RequestMethod.POST, RequestMethod.GET })
public @ResponseBody Map<String, String> fileCommit(
        @RequestParam(value = "id", defaultValue = "") String fileId, Principal principal) {

    Map<String, String> rtnJson = handler.commitFile(fileId, principal.getName());
    return rtnJson;
}

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

@RequestMapping(value = "/check-in/event/{eventName}/ticket/{ticketIdentifier}", method = POST)
public TicketAndCheckInResult checkIn(@PathVariable("eventName") String eventName,
        @PathVariable("ticketIdentifier") String ticketIdentifier, @RequestBody TicketCode ticketCode,
        @RequestParam(value = "offlineUser", required = false) String offlineUser, Principal principal) {
    String user = StringUtils.defaultIfBlank(offlineUser, principal.getName());
    return checkInManager.checkIn(eventName, ticketIdentifier,
            Optional.ofNullable(ticketCode).map(TicketCode::getCode), user);
}

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

@RequestMapping(value = "/check-in/event/{eventName}/ticket/{ticketIdentifier}/confirm-on-site-payment", method = POST)
public TicketAndCheckInResult confirmOnSitePayment(@PathVariable("eventName") String eventName,
        @PathVariable("ticketIdentifier") String ticketIdentifier, @RequestBody TicketCode ticketCode,
        @RequestParam(value = "offlineUser", required = false) String offlineUser, Principal principal) {
    String user = StringUtils.defaultIfBlank(offlineUser, principal.getName());
    return checkInManager.confirmOnSitePayment(eventName, ticketIdentifier,
            Optional.ofNullable(ticketCode).map(TicketCode::getCode), user);
}

From source file:com.jd.survey.web.settings.GlobalSettingsController.java

@Secured({ "ROLE_ADMIN" })
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Principal principal, Model uiModel) {
    log.info("updateForm(): id=" + id);
    try {// w  ww.  ja v  a2s  .c om
        User user = userService.user_findByLogin(principal.getName());
        if (!user.isAdmin()) {
            //log.warn("Unauthorized access to url path " + httpServletRequest.getPathInfo() + " attempted by user login:" + principal.getName() + "from IP:" + httpServletRequest.getLocalAddr());
            return "accessDenied";
        }
        populateEditForm(uiModel, applicationSettingsService.globalSettings_findById(id), user);
        return "settings/globalSettings/update";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

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

@Override
@RequestMapping(value = { "", "/" }, method = GET)
@ResponseBody/*  ww  w . j  a v  a 2 s. c o m*/
@ResponseView(ModelViews.FullUserView.class)
@ApiOperation("Return information about current logged-in user")
public UserResource getMyself(Principal principal) {
    return getUserHandler.getUser(EntityUtils.normalizeUsername(principal.getName()), principal);
}

From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.message.GPSecureMessageResource.java

@POST
@Path(value = GPServiceRSPathConfig.INSERT_MULTI_MESSAGE_PATH)
@Override/*  w  ww .j  a va  2s .  co m*/
public Boolean insertMultiMessage(@Auth Principal principal, MessageDTO messageDTO) throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@Executing secure insertMultiMessage - " + "Principal : {}\n\n",
            principal.getName());
    return super.insertMultiMessage(messageDTO);
}

From source file:alfio.controller.api.AdminApiController.java

@RequestMapping(value = "/events", method = GET)
public List<EventWithStatistics> getAllEvents(Principal principal) {
    return eventManager.getAllEventsWithStatistics(principal.getName());
}

From source file:pdl.web.controller.rest.RestMainController.java

/**
 * File upload request handler (POST, PUT)
 * @param file MultipartFile data in form
 * @return file information in json format
 * @format curl <ip address>:<port>/pdl/r/file/upload/?type=<type> -u <user id>:<pass> -F file=@<file> --keepalive-time <seconds> -X POST|PUT
 *
 * Admin users can upload tools such as python and cctools using this method.
 * @format curl <ip address>:<port>/pdl/r/file/upload/?type=tool:<tool> -u <user id>:<pass> -F file=@<file> --keepalive-time <seconds> -X POST|PUT
 *///from w w w . ja  v  a  2s  .  c om
@RequestMapping(value = "file/upload", method = { RequestMethod.POST, RequestMethod.PUT })
public @ResponseBody Map<String, String> fileUpload(@RequestParam("file") MultipartFile file,
        @RequestParam(value = "type", defaultValue = "") String type, Principal principal) {
    Map<String, String> rtnJson = handler.uploadFile(file, type, principal.getName());
    return rtnJson;
}

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

private void ensureOrganization(Principal principal, Organization organization) {
    User user = userManager.findUserByUsername(principal.getName());
    Validate.isTrue(userManager.isOwnerOfOrganization(user, organization.getId()));
}

From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.acl.GPSecureACLResource.java

@GET
@Path(value = GPServiceRSPathConfig.GET_ACCOUNT_PERMISSIONS_PATH)
@Override//  w w w .j a  v  a 2 s. c  om
public GuiComponentsPermissionMapData getAccountPermission(@Auth Principal principal,
        @PathParam(value = "accountID") Long accountID) throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@@Executing secure getAccountPermission" + " - Principal : {}\n\n",
            principal.getName());
    return super.getAccountPermission(accountID);
}