return globalPermissions().contains(globalPermission);
}
+ @Override
+ public boolean hasGlobalPermission(String globalPermission) {
+ return hasPermission(globalPermission);
+ }
+
@Override
public UserSession checkComponentPermission(String projectPermission, String componentKey) {
if (!hasComponentPermission(projectPermission, componentKey)) {
return get().hasPermission(globalPermission);
}
+ @Override
+ public boolean hasGlobalPermission(String globalPermission) {
+ return get().hasGlobalPermission(globalPermission);
+ }
+
@Override
public List<String> globalPermissions() {
return get().globalPermissions();
*/
boolean hasPermission(String globalPermission);
+ /**
+ * @deprecated Only used by Views and the Developer Cockpit.
+ */
+ @Deprecated
+ boolean hasGlobalPermission(String globalPermission);
+
List<String> globalPermissions();
/**
return currentUserSession.hasPermission(globalPermission);
}
+ @Override
+ public boolean hasGlobalPermission(String globalPermission) {
+ return currentUserSession.hasGlobalPermission(globalPermission);
+ }
+
@Override
public UserSession checkComponentPermission(String projectPermission, String componentKey) {
return currentUserSession.checkComponentPermission(projectPermission, componentKey);
session.checkComponentPermission(UserRole.USER, "another");
}
+ @Test
+ public void deprecated_has_global_permission() throws Exception {
+ UserSession session = newServerUserSession().setLogin(LOGIN);
+
+ when(authorizationDao.selectGlobalPermissions(LOGIN)).thenReturn(Arrays.asList("profileadmin", "admin"));
+
+ assertThat(session.hasGlobalPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN)).isTrue();
+ assertThat(session.hasGlobalPermission(GlobalPermissions.SYSTEM_ADMIN)).isTrue();
+ assertThat(session.hasGlobalPermission(GlobalPermissions.DASHBOARD_SHARING)).isFalse();
+ }
+
private ServerUserSession newServerUserSession() {
return new ServerUserSession(authorizationDao, resourceDao);
}