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.TestItemController.java

@Override
@PutMapping("/{item}/merge")
@ResponseBody/*from  ww  w .j  a  v a  2s  .c  om*/
@ResponseStatus(OK)
@PreAuthorize(ASSIGNED_TO_PROJECT)
@ApiOperation("Merge test item")
public OperationCompletionRS mergeTestItem(@PathVariable String projectName, @PathVariable String item,
        @RequestBody @Validated MergeTestItemRQ rq, Principal principal) {
    return mergeTestItemHandler.mergeTestItem(normalizeProjectName(projectName), item, rq, principal.getName());
}

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

/**
 * download file by UUID//from w  w  w.j a va  2  s  . c o  m
 * @return file information (UUID, absolute path) in json format
 * @format curl <ip address>:<port>/pdl/r/file/get/?id=<file id> -u <user id>:<pass> -o <filename> -X GET
 */
@RequestMapping(value = "file/get", method = RequestMethod.GET)
public void fileDownload(@RequestParam(value = "id", defaultValue = "") String fileId, Principal principal,
        HttpServletResponse res) {

    handler.downloadFile(fileId, res, principal.getName());
    return;
}

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

@RequestMapping(value = "EaddGastoR.htm", method = RequestMethod.POST)
public String addGastoR_post(@ModelAttribute("gasto") gastos gasto, BindingResult result, Principal principal) {
    String mensaje = "";
    String user = principal.getName();
    users u = null;/*  w  w w . j  av  a 2  s . c o  m*/
    try {
        u = usuarioService.getByLogin(user);
        gasto.setNif(u.getNif());
        gastosService.Insert(gasto);
        idPC = gastosService.ultimo(gasto);
    } catch (Exception e) {

    }
    return "redirect:EaddGastoRF.htm";

}

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

@Override
@RequestMapping(method = RequestMethod.POST, consumes = { APPLICATION_JSON_VALUE })
@ResponseBody/*from w  w w  . j a  v  a  2s. com*/
@PreAuthorize(PROJECT_LEAD)
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation("Register external system instance")
public EntryCreatedRS createExternalSystemInstance(@Validated @RequestBody CreateExternalSystemRQ createRQ,
        @PathVariable String projectName, Principal principal) {
    return createExternalSystemHandler.createExternalSystem(createRQ,
            EntityUtils.normalizeProjectName(projectName), principal.getName());
}

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

@Override
@RequestMapping(value = "/{systemId}", method = RequestMethod.DELETE)
@ResponseBody/*ww  w  .  ja  v a  2  s  .  co  m*/
@PreAuthorize(PROJECT_LEAD)
@ResponseStatus(HttpStatus.OK)
@ApiOperation("Delete registered external system instance")
public OperationCompletionRS deleteExternalSystem(@PathVariable String projectName,
        @PathVariable String systemId, Principal principal) {
    return deleteExternalSystemHandler.deleteExternalSystem(EntityUtils.normalizeProjectName(projectName),
            systemId, principal.getName());
}

From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.viewport.GPSecureViewportResource.java

@POST
@Path(value = GPServiceRSPathConfig.INSERT_VIEWPORT_PATH)
@Override//from w  ww . ja v  a  2  s  .c o  m
public Long insertViewport(@Auth Principal principal, InsertViewportRequest insertViewportReq)
        throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@Executing secure insertViewport - " + "Principal : {}\n\n",
            principal.getName());
    return super.insertViewport(insertViewportReq);
}

From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.viewport.GPSecureViewportResource.java

@PUT
@Path(value = GPServiceRSPathConfig.SAVE_OR_UPDATE_VIEWPORT_LIST_PATH)
@Override/*from w  w  w .  j  a  v  a2 s  .  co m*/
public void saveOrUpdateViewportList(@Auth Principal principal, ManageViewportRequest request)
        throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@Executing secure " + "saveOrUpdateViewportList - Principal : {}\n\n",
            principal.getName());
    super.saveOrUpdateViewportList(request);
}

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

/**
 * submit a job/*from   w  w w . j a  v  a 2  s .c  o m*/
 * @param jobName job identifier
 * @param inputInString json formate input
 * @param principal user principal
 * @return job submission result in json format
 * @format curl <ip address>:<port>/pdl/r/job/<jobname> -d '{"key":"value"}' -u <user id>:<pass> -H "Content-Type: application/json" -X POST
 */
@RequestMapping(value = "job/{name}", method = RequestMethod.POST)
public @ResponseBody Map<String, Object> submitJob(@PathVariable("name") String jobName,
        //format '{"key":"value"}': {"interpreter":<name>, "script":<id>, "input":<id>, ...}
        @RequestBody() final String inputInString, Principal principal) {

    Map<String, Object> jobResult = handler.submitJob(jobName, inputInString, principal.getName());
    return jobResult;
}

From source file:org.fcrepo.auth.xacml.XACMLAuthorizationDelegate.java

/**
 * Builds a global attribute finder from injected modules that may use
 * current session information./*w  w  w  .j a  va2 s. c  o m*/
 *
 * @param session the ModeShape session
 * @param absPath the node or property path
 * @param actions the actions requested
 * @return an attribute finder
 */
private EvaluationCtx buildEvaluationContext(final Session session, final String absPath,
        final String[] actions, final Set<String> roles) {
    final FedoraEvaluationCtxBuilder builder = new FedoraEvaluationCtxBuilder();
    builder.addFinderModule(currentEnvironmentAttributeModule);
    builder.addFinderModule(sparqlResourceAttributeFinderModule);

    // A subject attribute finder prototype is injected with Session
    // AttributeFinderModule subjectAttributeFinder = null;
    // if (applicationContext
    // .containsBeanDefinition(SUBJECT_ATTRIBUTE_FINDER_BEAN)) {
    // subjectAttributeFinder =
    // (AttributeFinderModule) applicationContext.getBean(
    // SUBJECT_ATTRIBUTE_FINDER_BEAN, session);
    // builder.addFinderModule(subjectAttributeFinder);
    // }

    // environment attribute finder is injected with Session
    // AttributeFinderModule environmentAttributeFinder = null;
    // if (applicationContext
    // .containsBeanDefinition(ENVIRONMENT_ATTRIBUTE_FINDER_BEAN)) {
    // environmentAttributeFinder =
    // (AttributeFinderModule) applicationContext.getBean(
    // ENVIRONMENT_ATTRIBUTE_FINDER_BEAN, session);
    // builder.addFinderModule(environmentAttributeFinder);
    // }

    // Triple attribute finder will look in modeshape for any valid
    // predicate URI, therefore it falls last in this list.
    builder.addFinderModule(tripleResourceAttributeFinderModule);
    LOGGER.debug("effective roles: {}", roles);

    final Principal user = (Principal) session.getAttribute(FEDORA_USER_PRINCIPAL);
    builder.addSubject(user.getName(), roles);
    builder.addResourceID(absPath);
    builder.addWorkspace(session.getWorkspace().getName());
    builder.addActions(actions);

    // add the original IP address
    final HttpServletRequest request = (HttpServletRequest) session.getAttribute(FEDORA_SERVLET_REQUEST);
    builder.addOriginalRequestIP(request.getRemoteAddr());

    // add user's groups
    @SuppressWarnings("unchecked")
    final Set<Principal> allGroups = (Set<Principal>) session.getAttribute(FEDORA_ALL_PRINCIPALS);
    LOGGER.debug("effective groups: {}", allGroups);
    builder.addGroups(user, allGroups);

    return builder.build();
}

From source file:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.folder.GPSecureFolderResource.java

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