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.dogjaw.services.authentication.ClientApplication.java

@RequestMapping("/")
public String home(Principal user) {
    return "Hello " + user.getName();
}

From source file:shiver.me.timbers.spring.security.integration.SpringSecurityController.java

@RequestMapping(method = GET, produces = TEXT_PLAIN_VALUE)
public String request(Principal principal) {
    return principal.getName();
}

From source file:com.lixiaocong.controller.DispatchController.java

@RolesAllowed("ROLE_USER")
@RequestMapping("/admin")
public ModelAndView admin(Principal princial) {
    User user = userService.getByUsername(princial.getName());
    if (user.isAdmin())
        return new ModelAndView("admin/superUser");
    return new ModelAndView("admin/normalUser");
}

From source file:com.orange.clara.tool.controllers.websocket.NotificationAckController.java

@MessageMapping("/notification.ack")
public void notificationAcknowledge(Principal principal) {
    User user = this.userRepo.findOne(principal.getName());
    user.updateLastWatch();/*from w w  w  .  j av a  2s .  com*/
    this.userRepo.save(user);
}

From source file:io.manasobi.security.UserDetailsController.java

@PreAuthorize("hasRole('USER')")
@RequestMapping(value = "/main", method = RequestMethod.GET)
public String main(Authentication auth, Principal principal) {

    System.out.println(principal.getName());

    //return "redirect:/license/history";      

    return "license/history";
}

From source file:com.promeets.model.service.webrtc.WebRtcSignalServiceImpl.java

@Override
public void signalRTCByMeetId(WebRtcSignalMessage message, Principal principal) {
    User currentUser = userService.getUserByEmail(principal.getName());
    message.setSuserId(currentUser.getUserId());
    notificationController.sendRtcSignalMessage(message);
}

From source file:org.alejandria.security.auth.RoleGranter.java

@Override
public Set<String> grant(Principal principal) {
    if (adminUsers.contains(principal.getName())) {
        return Collections.singleton("ADMIN");
    } else {//from w ww.j a  v  a  2 s. com
        return Collections.singleton("CUSTOMER");
    }
}

From source file:org.cloudfoundry.identity.uaa.oauth.ClientInfoEndpoint.java

@RequestMapping(value = "/clientinfo")
@ResponseBody//from   w  ww .  j  av a 2 s. com
public ClientDetails clientinfo(Principal principal) {

    String clientId = principal.getName();
    BaseClientDetails client = new BaseClientDetails(clientDetailsService.loadClientByClientId(clientId));
    client.setClientSecret(null);
    client.setAdditionalInformation(Collections.<String, Object>emptyMap());
    return client;

}

From source file:com.jayway.restassured.module.mockmvc.http.SecuredController.java

@RequestMapping(value = "/principalGreeting", method = GET)
public @ResponseBody Greeting greeting(
        @RequestParam(value = "name", required = false, defaultValue = "World") String name,
        Principal principal) {
    if (principal == null || !principal.getName().equals("authorized_user")) {
        throw new IllegalArgumentException("Not authorized");
    }//  w  w  w .ja va  2  s  .  c  o  m

    return new Greeting(counter.incrementAndGet(), String.format(template, name));
}

From source file:org.taverna.server.master.utils.UsernamePrincipal.java

public UsernamePrincipal(Principal other) {
    this.name = other.getName();
}