use of com.auth0.flickr2.domain.User in project iesi by metadew.
the class JwtService method generateAuthenticationResponse.
public AuthenticationResponse generateAuthenticationResponse(Authentication authentication) {
Algorithm algorithm = Algorithm.HMAC256(secret);
LocalDateTime now = LocalDateTime.now(clock);
LocalDateTime expiresAt = now.plus(accessTokenExpiryDate, ChronoUnit.SECONDS);
String token = JWT.create().withIssuer(ISSUER).withSubject(authentication.getName()).withIssuedAt(Timestamp.valueOf(now)).withExpiresAt(Timestamp.valueOf(expiresAt)).withClaim("uuid", ((IesiUserDetails) authentication.getPrincipal()).getId().toString()).sign(algorithm);
UserDto userDto = userService.get(((IesiUserDetails) authentication.getPrincipal()).getId()).orElseThrow(() -> new UsernameNotFoundException(String.format("Cannot find user %s (%s)", ((IesiUserDetails) authentication.getPrincipal()).getId().toString(), ((IesiUserDetails) authentication.getPrincipal()).getUsername())));
return new AuthenticationResponse(token, ChronoUnit.SECONDS.between(now, expiresAt), userDto.getRoles());
}
use of com.auth0.flickr2.domain.User in project code by lastwhispers.
the class UserController method login.
/**
* http://localhost:8080/user/login?username=admin&password=123456
*
* @param username
* @param password
* @return
*/
@GetMapping("/login")
public String login(@RequestParam String username, @RequestParam String password) {
Algorithm algorithm = Algorithm.HMAC256(JWT_KEY);
String token = JWT.create().withClaim(CURRENT_USER, username).withClaim(UID, 1).withExpiresAt(new Date(System.currentTimeMillis() + 3600000)).sign(algorithm);
return token;
}
use of com.auth0.flickr2.domain.User in project TCSS450-Mobile-App by TCSS450-Team7-MobileApp.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mMainActivity = this;
MainActivityArgs args = MainActivityArgs.fromBundle(getIntent().getExtras());
// Import com.auth0.android.jwt.JWT
JWT jwt = new JWT(args.getJwt());
// created on the web service.
if (!jwt.isExpired(0)) {
jwt = new JWT(args.getJwt());
}
new ViewModelProvider(this, new UserInfoViewModel.UserInfoViewModelFactory(args.getEmail(), jwt.toString(), args.getFirst(), args.getLast(), args.getNick(), args.getId())).get(UserInfoViewModel.class);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
// Make sure the new statements go BELOW setContentView
BottomNavigationView navView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder(R.id.navigation_message, R.id.navigation_home, R.id.navigation_weather).build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navView, navController);
mNewMessageModel = new ViewModelProvider(this).get(NewMessageCountViewModel.class);
navController.addOnDestinationChangedListener((controller, destination, arguments) -> {
if (destination.getId() == R.id.navigation_message) {
// When the user navigates to the chats page, reset the new message count.
// This will need some extra logic for your project as it should have
// multiple chat rooms.
mNewMessageModel.reset();
}
});
mNewMessageModel.addMessageCountObserver(this, count -> {
BadgeDrawable badge = binding.navView.getOrCreateBadge(R.id.navigation_message);
badge.setMaxCharacterCount(2);
if (count > 0) {
// new messages! update and show the notification badge.
badge.setNumber(count);
badge.setVisible(true);
} else {
// user did some action to clear the new messages, remove the badge
badge.clearNumber();
badge.setVisible(false);
}
});
}
use of com.auth0.flickr2.domain.User in project javasrc by IanDarwin.
the class TextToDBM method main.
public static void main(String[] fn) throws IOException {
BufferedReader is = new BufferedReader(new FileReader(TEXT_NAME));
DBM db = new DBM(DBM_NAME);
String line;
while ((line = is.readLine()) != null) {
if (line.startsWith("#")) {
// comment
continue;
}
StringTokenizer st = new StringTokenizer(line, ":");
String nick = st.nextToken();
String pass = st.nextToken();
String full = st.nextToken();
String email = st.nextToken();
String city = st.nextToken();
String prov = st.nextToken();
String ctry = st.nextToken();
User u = new User(nick, pass, full, email, city, prov, ctry);
String privs = st.nextToken();
if (privs.indexOf("A") != -1) {
u.setAdminPrivileged(true);
}
db.store(nick, u);
}
db.close();
is.close();
}
use of com.auth0.flickr2.domain.User in project javasrc by IanDarwin.
the class UserDBJDBC method deleteUser.
public void deleteUser(String nick) throws SQLException {
// Find the user object
User u = getUser(nick);
if (u == null) {
throw new SQLException("User " + nick + " not in in-memory DB");
}
deleteUserStmt.setString(1, nick);
int n = deleteUserStmt.executeUpdate();
if (n != 1) {
/*CANTHAPPEN */
throw new SQLException("ERROR: deleted " + n + " rows!!");
}
// IFF we deleted it from the DB, also remove from the in-memory list
users.remove(u);
}
Aggregations