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(value = "/names", method = RequestMethod.GET)
@ResponseBody/*from   www  . j  a  v a  2 s  .c  om*/
@ResponseStatus(HttpStatus.OK)
@ApiOperation("Get available filter names")
public Map<String, SharedEntity> getAllFiltersNames(@PathVariable String projectName, Principal principal,
        @RequestParam(value = "is_shared", defaultValue = "false", required = false) boolean isShared) {
    return getFilterHandler.getFiltersNames(principal.getName(), EntityUtils.normalizeProjectName(projectName),
            isShared);
}

From source file:com.jd.survey.web.surveys.SurveyController.java

/**
 * Shows a list of surveys for export to different formats
 * @param uiModel//from   www .  j a  va2s.  c  o  m
 * @param principal
 * @return
 */
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" })
@RequestMapping(value = "/report", produces = "text/html", method = RequestMethod.GET)
public String listSurveysForExport(Model uiModel, Principal principal) {
    try {
        User user = userService.user_findByLogin(principal.getName());
        List<SurveyStatistic> surveyStatistics = surveyService.surveyStatistic_getAll(user);
        uiModel.addAttribute("surveyStatistics", surveyStatistics);
        return "surveys/surveys";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

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

@RequestMapping(value = "/rest/sendEmail.json", method = RequestMethod.GET)
public @ResponseBody String sendEmail(Principal user, @RequestParam String toEmail) {
    logger.info("Sending email to=" + toEmail + " using user session=" + user.getName());
    try {//from  w  w  w. j av  a2  s.c o m
        return notesEmailClient.sendEmail("notemyweb@notemyweb.com", toEmail, "Easy way to take your notes");
    } catch (Exception e) {
        logger.error("Error while sending email to " + toEmail, e);
        return "Error while sending email to " + toEmail;
    }
}

From source file:com.jd.survey.web.surveys.SurveyController.java

/**
 * Shows a list of Survey Definitions // w  w  w. ja  va2s  . com
 * @param surveyId
 * @param principal
 * @param uiModel
 * @param httpServletRequest
 * @return
 */
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" })
@RequestMapping(produces = "text/html", method = RequestMethod.GET)
public String listSurveys(Model uiModel, Principal principal) {
    try {
        User user = userService.user_findByLogin(principal.getName());
        Set<SurveyDefinition> surveyDefinitions = surveySettingsService
                .surveyDefinition_findAllCompletedInternal(user);
        uiModel.addAttribute("surveyDefinitions", surveyDefinitions);
        return "surveys/entries";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

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

@Override
@PutMapping//w  w  w.j  a v a2  s .  c o  m
@ResponseStatus(OK)
@ResponseBody
@ApiOperation("Update issues of specified test items")
public List<Issue> defineTestItemIssueType(@PathVariable String projectName,
        @RequestBody @Validated DefineIssueRQ request, Principal principal) {
    return updateTestItemHandler.defineTestItemsIssues(normalizeProjectName(projectName), request,
            principal.getName());
}

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

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

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

@PUT
@Path(value = GPServiceRSPathConfig.MARK_MESSAGE_AS_READ_PATH)
@Override//from  w w w.j  av  a 2 s.c o  m
public Boolean markMessageAsRead(@Auth Principal principal, @PathParam(value = "messageID") Long messageID)
        throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@Executing secure markMessageAsRead - " + "Principal : {}\n\n",
            principal.getName());
    return super.markMessageAsRead(messageID);
}

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

@GET
@Path(value = GPServiceRSPathConfig.GET_ALL_SERVERS_PATH)
@Override/*from   w ww.j  ava  2  s.  com*/
public ServerDTOContainer getAllServers(@Auth Principal principal,
        @PathParam(value = "organizazionName") String organizazionName) throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@Executing secure getAllServers - " + "Principal : {}\n\n",
            principal.getName());
    return super.getAllServers(organizazionName);
}

From source file:com.jd.survey.web.security.AuthorityController.java

@Secured({ "ROLE_ADMIN" })
@RequestMapping(params = "create", produces = "text/html")
public String createGet(Principal principal, Model uiModel, HttpServletRequest httpServletRequest) {
    try {/*w  ww. jav a2  s  . c o  m*/
        User user = userService.user_findByLogin(principal.getName());
        SecurityObject authority = new Authority();
        populateEditForm(uiModel, authority, user);
        return "security/authorities/create";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

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

@Override
@RequestMapping(value = "/{projectName}/preference/{login}", method = RequestMethod.PUT)
@ResponseBody//from w  w w  . j ava 2s.  c o  m
@ResponseStatus(HttpStatus.OK)
@PreAuthorize(ALLOWED_TO_EDIT_USER)
@ApiIgnore
// Hide method cause results using for UI only and doesn't affect WS
public OperationCompletionRS updateUserPreference(@PathVariable String projectName,
        @RequestBody @Validated UpdatePreferenceRQ updatePreferenceRQ, @PathVariable String login,
        Principal principal) {
    return updatePreferenceHandler.updatePreference(principal.getName(),
            EntityUtils.normalizeProjectName(projectName), updatePreferenceRQ);
}