Search in sources :

Example 51 with User

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;
}
Also used : Player(org.libresonic.player.domain.Player) User(org.libresonic.player.domain.User)

Example 52 with User

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;
}
Also used : User(org.libresonic.player.domain.User)

Aggregations

User (org.libresonic.player.domain.User)52 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)33 ModelAndView (org.springframework.web.servlet.ModelAndView)10 HashMap (java.util.HashMap)8 Test (org.junit.Test)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 Share (org.libresonic.player.domain.Share)6 UserSettings (org.libresonic.player.domain.UserSettings)6 MusicFolder (org.libresonic.player.domain.MusicFolder)5 Player (org.libresonic.player.domain.Player)4 UserSettingsCommand (org.libresonic.player.command.UserSettingsCommand)3 Playlist (org.libresonic.player.domain.Playlist)3 org.libresonic.restapi (org.libresonic.restapi)3 RedirectView (org.springframework.web.servlet.view.RedirectView)3 File (java.io.File)2 Date (java.util.Date)2 MediaFile (org.libresonic.player.domain.MediaFile)2 GrantedAuthority (org.springframework.security.core.GrantedAuthority)2 LinkedHashMap (java.util.LinkedHashMap)1 ReCaptcha (net.tanesha.recaptcha.ReCaptcha)1