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.web.GenericController.java

@RequestMapping(value = "fileupload", method = RequestMethod.POST)
public String processUpload(@RequestParam("file") MultipartFile file, @RequestParam("type") String type,
        Model model, Principal principal) {

    try {//  w w w.  j  a va2  s.  c o m
        FileService fileService = new FileService();
        fileService.uploadFile(file, type, principal.getName());
    } catch (Exception ex) {

    }

    model.addAttribute("message", "File '" + file.getOriginalFilename() + "' uploaded successfully");

    return "fileupload";
}

From source file:runtheshow.resource.metiers.SousEvenenementMetier.java

@Override
public List<SousEvenement> getAllSousEvent(Principal user) {
    return Lists.newArrayList(sousEventRepository.findByUser(userRepository.findUserByLogin(user.getName())));
}

From source file:au.csiro.notify.rest.NotificationRestService.java

@Override
public XMLNotifications getAll(boolean includeRead) {
    logger.trace("entering getAll({})", includeRead);
    Principal p = sc.getUserPrincipal();
    logger.debug("{}, {}", p.getName(), p);
    XMLNotifications response = assembler
            .createXMLNotifications(notificationService.retrieveAll(includeRead, sc.getUserPrincipal()));
    logger.trace("exiting getAll={}", response);
    return response;
}

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

@Override
@RequestMapping(value = "/{dashboardId}", method = RequestMethod.DELETE)
@ResponseStatus(OK)/*from ww w  . j a  v  a 2s. co m*/
@ResponseBody
@ApiOperation("Delete specified dashboard by ID for specified project")
public OperationCompletionRS deleteDashboard(@PathVariable String projectName, @PathVariable String dashboardId,
        Principal principal) {
    return deleteHandler.deleteDashboard(dashboardId, principal.getName(),
            EntityUtils.normalizeProjectName(projectName));
}

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

/**
 * API for external apps that load the ticket using its UUID. It is possible to retrieve a ticket only if <b>all</b> the following conditions are met:
 *
 * <ul>/*w w w  . ja  v  a2 s .  c  o  m*/
 *     <li>An event with key {@code eventKey} exists</li>
 *     <li>The user and the event belong to the same organization</li>
 *     <li>A ticket with UUID {@code UUID} exists</li>
 * </ul>
 *
 * otherwise, an error is returned.
 *
 * @param eventShortName
 * @param uuid
 * @param principal
 * @return
 */
@GetMapping("/{eventKey}/ticket/{UUID}")
public Result<Ticket> getTicketDetails(@PathVariable("eventKey") String eventShortName,
        @PathVariable("UUID") String uuid, Principal principal) {
    return attendeeManager.retrieveTicket(eventShortName, uuid, principal.getName());
}

From source file:com.eretailservice.security.BookingRestController.java

@RequestMapping(method = RequestMethod.POST)
ResponseEntity<?> add(Principal principal, @RequestBody Booking input) {
    this.validateUser(principal);

    return accountRepository.findByUsername(principal.getName()).map(account -> {
        Booking booking = bookingRepository.save(new Booking(account, input.uri, input.description));

        Link forOneBooking = new BookingResource(booking).getLink(Link.REL_SELF);

        return ResponseEntity.created(URI.create(forOneBooking.getHref())).build();
    }).orElse(ResponseEntity.noContent().build());
}

From source file:mx.gob.cfe.documentos.web.CircularController.java

@RequestMapping
public String lista(Model model, Principal principal) {
    String username = principal.getName();
    Usuario usuario = usuarioDao.obtinePorUsername(username);
    model.addAttribute("circulares", instance.lista("Circular", usuario.getIniciales()));
    List lista = instance.lista("Circular", usuario.getIniciales());
    log.error("lista{}", lista);
    return "circular/lista";
}

From source file:mx.gob.cfe.documentos.web.MemoController.java

@RequestMapping
public String lista(Model model, Principal principal) {
    String username = principal.getName();
    Usuario usuario = usuarioDao.obtinePorUsername(username);
    model.addAttribute("memos", instance.lista("Memo", usuario.getIniciales()));
    List lista = instance.lista("Memo", usuario.getIniciales());
    log.error("lista{}", lista);
    return "memo/lista";
}

From source file:org.smigo.user.UserSetLocaleResolver.java

@Override
public Locale resolveLocale(HttpServletRequest req) {
    final Principal userPrincipal = req.getUserPrincipal();
    if (userPrincipal != null) {
        User user = userDao.getUsersByUsername(userPrincipal.getName()).get(0);
        if (user.getLocale() != null) {
            return user.getLocale();
        }/* w ww.  j ava 2s  . c o m*/
    }

    final String subDomain = req.getServerName().split("\\.")[0];
    for (Language language : Language.values()) {
        if (language.getLocale().getLanguage().equals(subDomain)) {
            return new Locale(subDomain);
        }
    }

    return req.getLocale() == null ? Locale.ENGLISH : req.getLocale();
}

From source file:mx.gob.cfe.documentos.web.MemoInterController.java

@RequestMapping
public String lista(Model model, Principal principal) {
    String username = principal.getName();
    Usuario usuario = usuarioDao.obtinePorUsername(username);
    model.addAttribute("memosInter", instance.lista("Memo Inter", usuario.getIniciales()));
    List lista = instance.lista("Memo Inter", usuario.getIniciales());
    log.error("lista{}", lista);
    return "memoInter/lista";
}