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.iana.dver.controller.LoginController.java

@RequestMapping(value = "/welcome", method = RequestMethod.GET)
public String doWelcomeDver(final RedirectAttributes redirectAttributes, HttpServletRequest request,
        Principal user) {
    String name = user.getName();
    String redirect = "index";
    this.securityObj = loginService.login(name);
    request.getSession().setAttribute("securityObj", securityObj);
    final String userType = securityObj.getUserType();
    if (userType.equalsIgnoreCase("Admin") || userType.equalsIgnoreCase("IEP")
            || userType.equalsIgnoreCase("MC")) {
        redirect = "redirect:/" + userType.toLowerCase();
    } else {/*from   w  w w  . j av  a 2s .  com*/
        redirectAttributes.addFlashAttribute("failureMessage", "Invalid Username or Password");
    }
    return redirect;
}

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

/**
 * Este metodo inicia el proceso para la descarga de informacion
 *
 * @param id/* w  w w  . j a  v a 2s. c om*/
 * @param response
 * @param principal
 * @return con el response regresa el pdf con la informacion adecuada
 * @throws JRException
 * @throws IOException
 */
@RequestMapping(value = "/download", method = RequestMethod.GET)
public String getDownloadPage(@PathVariable Long id, HttpServletResponse response, Principal principal)
        throws JRException, IOException {
    log.debug("Received request to show download page");
    String username = principal.getName();
    Usuario usuario = usuarioDao.obtinePorUsername(username);
    if (!usuario.isAdministrador()) {
        return "usuario/noAutorizado";
    }
    List<Documento> documentos = instance.listaDocumentosCompleto();
    generaReporte("PDF", documentos, response);

    return "redirect:/depurar";
}

From source file:com.intranet.intr.contabilidad.EmpControllerGastos.java

@RequestMapping("EGastos.htm")
public ModelAndView DocumentosContratosList(ModelAndView mav, Principal principal) {
    String name = principal.getName();
    users u = null;//w  ww.j a  v  a 2s  .c om
    List<gastos> gastosListbox = null;
    try {
        u = usuarioService.getByLogin(name);
        gastosListbox = gastosService.findAllEmpleado(u.getNif());
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("entra a funcion documento");
    }
    //ModelAndView mav=new ModelAndView();
    String r = validaInterfacesRoles.valida();
    mav.addObject("menu", r);
    mav.addObject("gastosListbox", gastosListbox);
    mav.setViewName("EGastos");
    return mav;
}

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

/**
 * Obtain new File UUID/*w  ww .j  a va2 s. c o  m*/
 * @return file information (UUID, absolute path) in json format
 * @format curl <ip address>:<port>/pdl/r/file/new -u <user id>:<pass> -X POST|GET
 */
@RequestMapping(value = "file/new", method = { RequestMethod.POST, RequestMethod.GET })
public @ResponseBody Map<String, String> fileCreate(Principal principal) {

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

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

@RequestMapping(value = "/event/{eventName}/{reservationId}/refund", method = RequestMethod.POST)
public Result<Boolean> refund(@PathVariable("eventName") String eventName,
        @PathVariable("reservationId") String reservationId, @RequestBody RefundAmount amount,
        Principal principal) {
    return adminReservationManager.refund(eventName, reservationId, new BigDecimal(amount.amount),
            principal.getName());
}

From source file:au.csiro.notify.service.NotificationServiceImpl.java

@Override
@Transactional(readOnly = true)/*from   w  w w .  j av a2 s  .c o  m*/
public Notification retrieve(long id, Principal principal) throws NotFoundException {
    logger.trace("entering retrieve({})", id);
    Notification n = notificationDao.findOneByRecipient(id, principal.getName());
    if (n == null) {
        logger.trace("exiting retrieve");
        throw new NotFoundException(Notification.class, id);
    }
    logger.trace("exiting retrieve({})", n);
    return n;
}

From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.server.GPSecureServerResource.java

@PUT
@Path(value = GPServiceRSPathConfig.SAVE_SERVER_PATH)
@Override//from  w w w  . j  a  va  2s.c  om
public ServerDTO saveServer(@Auth Principal principal, WSSaveServerRequest saveServerReq) throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@Executing secure saveServer - " + "Principal : {}\n\n",
            principal.getName());
    return super.saveServer(saveServerReq);
}

From source file:com.notemyweb.controller.RestController.java

@RequestMapping(value = "/rest/isFbPostEnabled.json", method = RequestMethod.POST)
public void isFbPostEnabled(Principal user, @RequestParam Boolean isFbPostEnabled) {
    User awsUser = new User(user.getName()).setIsFbPostEnabled(isFbPostEnabled);
    notesDao.updateUser(awsUser);/* ww w  .j  av a2 s  .  co m*/
}

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

@POST
@Path(value = GPServiceRSPathConfig.INSERT_MESSAGE_PATH)
@Override//from   w  ww  .  j a v  a 2  s  .  com
public Long insertMessage(@Auth Principal principal, GPMessage message) throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@@@@Executing secure insertMessage - " + "Principal : {}\n\n",
            principal.getName());
    return super.insertMessage(message);
}

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

@Secured({ "ROLE_ADMIN" })
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Principal principal, Model uiModel) {
    log.info("show(): id=" + id);

    try {// w  w  w .j  a v a2  s. c o  m
        User user = userService.user_findByLogin(principal.getName());
        if (!user.isAdmin()) {
            return "accessDenied";
        }
        uiModel.addAttribute("globalSettings", applicationSettingsService.globalSettings_findById(id));
        return "settings/globalSettings/show";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}