Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added /api/username
  • Loading branch information
selvasingh committed Oct 3, 2019
commit b78ab70d805920a65d21eda404dd9b3a605dbca4
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for
* license information.
*/

package org.inventory.hub.controller;

import java.security.Principal;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@ResponseBody
public class SecurityController {

public SecurityController() {
}

@RequestMapping(value = "/api/username", method = RequestMethod.GET)
public String currentUsername(final Principal principal) {

System.out.println("======= /api/username ===== ");
String username = new String();
if (principal != null)
username = principal.getName();

System.out.println("username=" + username);
System.out.println("====== success");

return username;
}

}