use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class PlayerService method getGuestPlayer.
/**
* Returns a player associated to the special "guest" user, creating it if necessary.
*/
public Player getGuestPlayer(HttpServletRequest request) {
// Create guest user if necessary.
User user = securityService.getUserByName(User.USERNAME_GUEST);
if (user == null) {
user = new User(User.USERNAME_GUEST, RandomStringUtils.randomAlphanumeric(30), null);
user.setStreamRole(true);
securityService.createUser(user);
}
// Look for existing player.
List<Player> players = getPlayersForUserAndClientId(User.USERNAME_GUEST, null);
if (!players.isEmpty()) {
return players.get(0);
}
// Create player if necessary.
Player player = new Player();
if (request != null) {
player.setIpAddress(request.getRemoteAddr());
}
player.setUsername(User.USERNAME_GUEST);
createPlayer(player);
return player;
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class SonosService method getSessionId.
@Override
public GetSessionIdResponse getSessionId(GetSessionId parameters) {
LOG.debug("getSessionId: " + parameters.getUsername());
User user = securityService.getUserByName(parameters.getUsername());
if (user == null || !StringUtils.equals(user.getPassword(), parameters.getPassword())) {
throw new SonosSoapFault.LoginInvalid();
}
// Use username as session ID for easy access to it later.
GetSessionIdResponse result = new GetSessionIdResponse();
result.setGetSessionIdResult(user.getUsername());
return result;
}
Aggregations