31 lines
836 B
Java
31 lines
836 B
Java
|
|
package zall.manager;
|
||
|
|
|
||
|
|
import zall.bean.Folder;
|
||
|
|
import zall.bean.Media;
|
||
|
|
import zall.bean.User;
|
||
|
|
|
||
|
|
/**
|
||
|
|
*
|
||
|
|
*/
|
||
|
|
public class AuthenticationManager {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @return true if the specified user can edit the media
|
||
|
|
*/
|
||
|
|
public static boolean canEdit(User user, Media target) {
|
||
|
|
return target != null && (user.isSuperUser() || target.getUser().equals(user));
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* @return true if the specified user can edit the media
|
||
|
|
*/
|
||
|
|
public static boolean canEdit(User user, Folder target) {
|
||
|
|
return target != null && (user.isSuperUser() || user.equals( target.getUser() ));
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* @return true if the specified user can edit the profile of the other user
|
||
|
|
*/
|
||
|
|
public static boolean canEdit(User user, User target){
|
||
|
|
return user.equals( target ) || user.isSuperUser();
|
||
|
|
}
|
||
|
|
}
|