Newer
Older
/*
* This file is part of vospace-file-service
* Copyright (C) 2021 Istituto Nazionale di Astrofisica
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package it.inaf.ia2.transfer.controller;
import it.inaf.ia2.transfer.auth.TokenPrincipal;
import it.inaf.oats.vospace.exception.PermissionDeniedException;
public abstract class AuthenticatedFileController extends FileController {
protected TokenPrincipal getPrincipal() {
TokenPrincipal principal = (TokenPrincipal) request.getUserPrincipal();
if ("anonymous".equals(principal.getName())) {
throw new PermissionDeniedException(this.getCustomAuthErrorMessage());
}
return principal;
}
protected abstract String getCustomAuthErrorMessage();
}