Newer
Older
import eu.hbp.mip.utils.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
public class GalaxyAuthentication {
private final ActiveUserService activeUserService;
@Value("#{'${services.galaxy.galaxyUsername:admin}'}")
private String galaxyUsername;
@Value("#{'${services.galaxy.galaxyPassword:password}'}")
private String galaxyPassword;
@Value("#{'${services.galaxy.galaxpathoyContext:nativeGalaxy}'}")
public GalaxyAuthentication(ActiveUserService activeUserService) {
this.activeUserService = activeUserService;
}
/**
* Get Galaxy Reverse Proxy basic access token.
*
* @return Return a @{@link ResponseEntity} with the token.
*/
@RequestMapping(path = "/galaxy", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('WORKFLOW_ADMIN')")
Logger logger = new Logger(activeUserService.getActiveUser().getUsername(), "(GET) /user/galaxy");
String stringEncoded = Base64.getEncoder().encodeToString((galaxyUsername + ":" + galaxyPassword).getBytes());
logger.LogUserAction("Successfully Loaded galaxy information.");
return ResponseEntity.ok(new Gson().toJson(object));