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:org.geosdi.geoplatform.experimental.dropwizard.resources.secure.message.GPSecureMessageResource.java

@PUT
@Path(value = GPServiceRSPathConfig.MARK_MESSAGES_AS_READ_BY_DATE_PATH)
@Override/* ww  w .j  a va  2s  .com*/
public Boolean markMessagesAsReadByDate(@Auth Principal principal,
        MarkMessageReadByDateRequest markMessageAsReadByDateReq) throws Exception {
    logger.debug("\n\n@@@@@@@@@@@@@@Executing secure" + " markMessagesAsReadByDate - Principal : {}\n\n",
            principal.getName());
    return super.markMessagesAsReadByDate(markMessageAsReadByDateReq);
}

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

/**
 * update job status to failed/*from w  w  w.  j a va  2s.c  o  m*/
 * @param jobId job UUID
 * @return result in json format
 * @format curl <ip address>:<port>/pdl/r/status/complete?jid=<jobid>  -u <user id>:<pass> -X POST|GET
 */
@RequestMapping(value = "status/fail", method = { RequestMethod.POST, RequestMethod.GET })
public @ResponseBody Map<String, String> setJobFail(
        @RequestParam(value = "jid", defaultValue = "") String jobId, Principal principal) {
    Map<String, String> jsonResult = handler.updateJob(jobId, StaticValues.JOB_STATUS_FAILED, null,
            principal.getName());
    return jsonResult;
}

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

@RequestMapping(value = "/check-in/{eventName}/offline", method = POST)
public Map<String, String> getOfflineEncryptedInfo(@PathVariable("eventName") String eventName,
        @RequestParam(value = "additionalField", required = false) List<String> additionalFields,
        @RequestBody List<Integer> ids, Principal principal) {

    validateIdList(ids);//from   ww w .  j av  a 2  s  .c  o m
    return optionally(() -> eventManager.getSingleEvent(eventName, principal.getName())).map(event -> {
        Set<String> addFields = loadLabelLayout(event).map(layout -> {
            Set<String> union = new HashSet<>(layout.content.thirdRow);
            union.addAll(layout.qrCode.additionalInfo);
            if (additionalFields != null && !additionalFields.isEmpty()) {
                union.addAll(additionalFields);
            }
            return union;
        }).orElseGet(() -> {
            if (additionalFields != null && !additionalFields.isEmpty()) {
                return new HashSet<>(additionalFields);
            }
            return Collections.singleton("company");
        });
        return checkInManager.getEncryptedAttendeesInformation(event, addFields, ids);
    }).orElse(Collections.emptyMap());
}

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

/**
 * Shows the logged in user information 
 * @param principal/*  w ww .j  av  a  2s  . c  o  m*/
 * @param uiModel
 * @return
 */
@Secured({ "ROLE_SURVEY_ADMIN" })
@RequestMapping(value = "/show", produces = "text/html")
public String show(Principal principal, Model uiModel) {
    try {
        User loggedInUser = userService.user_findByLogin(principal.getName());
        uiModel.addAttribute("user", loggedInUser);
        return "account/show";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

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

/**
 * Prepares to update  logged in user password
 * @param principal/*from   ww w. j a  v a2s  .com*/
 * @param uiModel
 * @return
 */
@Secured({ "ROLE_SURVEY_ADMIN" })
@RequestMapping(value = "/rpass", produces = "text/html")
public String userUpdatePassword(Principal principal, Model uiModel) {
    try {
        User loggedInUser = userService.user_findByLogin(principal.getName());
        uiModel.addAttribute("user", loggedInUser);
        return "account/rpass";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}

From source file:com.zanshang.controllers.web.SettingController.java

@RequestMapping(value = { "/publisher/apply", "/application/publisher" }, method = RequestMethod.POST)
@Secured("ROLE_USER")
@ResponseBody/*ww w  .j a  v  a  2  s .  c  om*/
public Object applyPublisher(Principal principal, Locale locale) {
    ObjectId uid = new ObjectId(principal.getName());
    Company company = companyService.get(uid);
    if (company == null) {
        return Ajax.failure(messageSource.getMessage("setting.personal.apply_publisher", null, locale));
    } else {
        publisherService.submit(uid);
        return Ajax.ok();
    }
}

From source file:com.capstone.giveout.controllers.GiftsController.java

@PreAuthorize("hasRole(mobile)")
@RequestMapping(value = Routes.MY_GIFTS_PATH, method = RequestMethod.GET)
public @ResponseBody Collection<Gift> listMine(
        @RequestParam(value = Routes.TITLE_PARAMETER, required = false) String title,
        @RequestParam(value = Routes.PAGE_PARAMETER, required = false, defaultValue = "0") int page,
        @RequestParam(value = Routes.LIMIT_PARAMETER, required = false, defaultValue = Constants.DEFAULT_PAGE_SIZE) int limit,
        Principal p) {
    User u = users.findByUsername(p.getName());
    PageRequest pageRequest = new PageRequest(page, limit, new Sort(Sort.Direction.DESC, "createdAt"));

    List<Gift> giftList;//from  w  w w. j a  v  a 2  s  . c o  m
    if (title == null) {
        giftList = Lists.newArrayList(gifts.findByUserId(u.getId(), pageRequest));
    } else {
        giftList = Lists
                .newArrayList(gifts.findByUserIdAndTitleLike(u.getId(), "%" + title + "%", pageRequest));
    }
    for (Gift gift : giftList) {
        gift.allowAccessToGiftChain = true;
    }
    return giftList;
}

From source file:fi.okm.mpass.shibboleth.profile.impl.AbstractAuthnFlowRestResponseAction.java

/**
 * Gets the list of tags for the given flow. They are parsed from the list of supported principals of the flow.
 * //  www  .j  a va2  s.com
 * @param flow The authentication flow.
 * @param id The authentication flow identifier.
 * @return The list of tags.
 */
protected List<String> getTags(final AuthenticationFlowDescriptor flow, final String id) {
    final List<String> tags = new ArrayList<>();
    for (final Principal principal : flow.getSupportedPrincipals()) {
        final String name = principal.getName();
        if (name.startsWith(AuthenticationDiscoveryContext.TAG_PRINCIPAL_PREFIX)) {
            final String strippedName = name
                    .substring((AuthenticationDiscoveryContext.TAG_PRINCIPAL_PREFIX).length());
            tags.add(strippedName);
            log.debug("{} Added {} as a tag for {}", getLogPrefix(), strippedName, id);
        } else {
            log.trace("{} Ignoring {} from the list of tags", getLogPrefix(), name);
        }
    }
    return tags;
}

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

/**
 * prepares for user update information 
 * @param principal//from   w  w w .  j  a v a  2 s  .  c  o m
 * @param uiModel
 * @return
 */
@Secured({ "ROLE_SURVEY_ADMIN" })
@RequestMapping(value = "/update", produces = "text/html")
public String updateForm(Principal principal, Model uiModel) {

    try {
        User loggedInUser = userService.user_findByLogin(principal.getName());
        uiModel.addAttribute("user", loggedInUser);
        return "account/update";
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw (new RuntimeException(e));
    }
}