本文整理汇总了Java中org.trustedanalytics.cloud.cc.api.CcOrgPermission类的典型用法代码示例。如果您正苦于以下问题:Java CcOrgPermission类的具体用法?Java CcOrgPermission怎么用?Java CcOrgPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CcOrgPermission类属于org.trustedanalytics.cloud.cc.api包,在下文中一共展示了CcOrgPermission类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAccessibleOrgs
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
@Override public Collection<CcOrgPermission> getAccessibleOrgs(HttpServletRequest request)
throws IOException, ServletException {
LOGGER.debug("Collecting user's orgs");
String token;
try {
token = getToken(request);
} catch (OauthTokenMissingException e) {
LOGGER.debug(e.getMessage(), e);
return new ArrayList<CcOrgPermission>() {
};
}
String url = userManagementBaseUrl + "/rest/orgs/permissions";
ResponseEntity<CcOrgPermission[]> access = RestOperationsHelpers.getForEntityWithToken(
new RestTemplate(), token, url, CcOrgPermission[].class);
return Arrays.asList(access.getBody());
}
示例2: postRequest_emptySource_shouldREturn400
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
@Test
public void postRequest_emptySource_shouldREturn400()
throws InterruptedException, IOException, ServletException {
when(tokenRetriever.getAuthToken(any(Authentication.class))).thenReturn(TOKEN);
CcOrg org = new CcOrg(UUID.fromString("11111111-2222-3333-4444-555555555555"), "fakeName");
CcOrgPermission permission = new CcOrgPermission();
permission.setOrganization(org);
prepareAccessibleOrgList(permission);
ResponseEntity<String> response =
testRestTemplate.postForEntity(effectiveBaseUrl,
new Request.RequestBuilder(0, "").withOrgUUID(org.getGuid().toString()).build(),
String.class);
assertThat(response.getStatusCode(), equalTo(HttpStatus.BAD_REQUEST));
}
示例3: getPermissions
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
@ApiOperation(
value = "Returns permissions for user within specified organizations.",
notes = "Privilege level: Any consumer of this endpoint must have a valid access token"
)
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK", response = CcOrgPermission.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Internal server error, e.g. error connecting to CloudController")
})
@RequestMapping(value = "/rest/orgs/permissions", method = GET)
public Collection<CcOrgPermission> getPermissions(@RequestParam(required = false) String orgs,
Authentication authentication) {
final List<UUID> organizations = new ArrayList<>();
if (!Strings.isNullOrEmpty(orgs)) {
organizations.addAll(
Arrays.asList(orgs.split(",")).stream().map(UUID::fromString).collect(toList()));
}
return resolvePermissions(organizations, authentication);
}
示例4: permissionsEndpoint_WithoutFilter_ShouldReturnAll
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
@Test
public void permissionsEndpoint_WithoutFilter_ShouldReturnAll() {
CcOrgsList orgsReturnedByCf = OrgsTestsResources.getOrgsReturnedByCf();
CcOrgsList emptyOrgList = new CcOrgsList();
emptyOrgList.setOrgs(new ArrayList<>());
when(detailsFinder.findUserId(Mockito.any())).thenReturn(UUID.randomUUID());
when(ccClient.getUserPermissions(any(), any()))
.thenReturn(
orgsReturnedByCf.getOrgs().stream().map(org ->
new CcOrgPermission(org,
/*isManager*/true,
/*isAuditor*/ false,
/*isBillingManager*/false)).collect(Collectors.toList())
);
TestRestTemplate testRestTemplate = new TestRestTemplate();
CcOrgPermission[] valueReturned =
testRestTemplate.getForObject(BASE_URL + "/rest/orgs/permissions", CcOrgPermission[].class);
assertEquals(2, valueReturned.length);
for (CcOrgPermission permission : valueReturned) {
assertTrue(permission.isManager());
}
}
示例5: getUserPermissions
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
@Override public Collection<CcOrgPermission> getUserPermissions(UUID user, Collection<UUID> orgsFilter) {
Collection<CcOrg> orgs = userResource.getUserOrganizations(user).getOrgs();
if(!orgsFilter.isEmpty()) {
orgs.removeIf(ccOrg -> !orgsFilter.contains(ccOrg.getGuid()));
}
Collection<CcOrg> managedOrganizations = getManagedOrganizations(user);
Collection<CcOrg> auditedOrganizations = getAuditedOrganizations(user);
Collection<CcOrg> billingManagedOrganizations = getBillingManagedOrganizations(user);
Collection<CcOrgPermission> permissions = new ArrayList<>();
orgs.forEach(org -> {
boolean isManager = managedOrganizations.contains(org);
boolean isAuditor = auditedOrganizations.contains(org);
boolean isBillingManager = billingManagedOrganizations.contains(org);
permissions.add(new CcOrgPermission(org, isManager, isAuditor, isBillingManager));
});
return permissions;
}
示例6: getUserPermissions
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
@Override public Collection<CcOrgPermission> getUserPermissions(UUID user, Collection<UUID> orgsFilter) {
Collection<CcOrg> orgs = getUserOrgs(user);
if(!orgsFilter.isEmpty()) {
orgs.removeIf(ccOrg -> !orgsFilter.contains(ccOrg.getGuid()));
}
Collection<CcOrg> managedOrganizations = getManagedOrganizations(user);
Collection<CcOrg> auditedOrganizations = getAuditedOrganizations(user);
Collection<CcOrg> billingManagedOrganizations = getBillingManagedOrganizations(user);
Collection<CcOrgPermission> permissions = new ArrayList<>();
orgs.forEach(org -> {
boolean isManager = managedOrganizations.contains(org);
boolean isAuditor = auditedOrganizations.contains(org);
boolean isBillingManager = billingManagedOrganizations.contains(org);
permissions.add(new CcOrgPermission(org, isManager, isAuditor, isBillingManager));
});
return permissions;
}
示例7: postRequest
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
@Test
public void postRequest()
throws InterruptedException, IOException, ServletException {
when(tokenRetriever.getAuthToken(any(Authentication.class))).thenReturn(TOKEN);
CcOrg org = new CcOrg(UUID.fromString("11111111-2222-3333-4444-555555555555"), "fakeName");
CcOrgPermission permission = new CcOrgPermission();
permission.setOrganization(org);
prepareAccessibleOrgList(permission);
ResponseEntity<RequestDTO> response =
testRestTemplate.postForEntity(effectiveBaseUrl,
new Request.RequestBuilder(0, "http://foo/bar.txt").withOrgUUID(org.getGuid().toString()).build(),
RequestDTO.class);
assertThat(response.getStatusCode(), equalTo(HttpStatus.ACCEPTED));
String requestId = response.getBody().getId();
executor.scheduleWithFixedDelay(() -> {
final RequestDTO addedRequest = testRestTemplate.getForObject(effectiveBaseUrl + "/{id}", RequestDTO.class, requestId);
statusListenerMock.found(addedRequest.getState());
}, 0, 100, TimeUnit.MILLISECONDS);
verify(statusListenerMock, timeout(500)).found(eqState(State.FINISHED));
verify(authorization, times(2))
.getAccessibleOrgs(any(HttpServletRequest.class));
//FIXME: verify the file content and the metadata are stored.
}
示例8: resolvePermissions
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
/**
* Returns permissions for user within specified organizations.
*
* @param orgs UUIDs
* @param authentication authentication
* @return permissions
*/
private Collection<CcOrgPermission> resolvePermissions(Collection<UUID> orgs,
Authentication authentication) {
final UUID user = detailsFinder.findUserId(authentication);
final UserRole role = detailsFinder.getRole(authentication);
LOGGER.info("Resolving permissions for user: {}", user.toString());
return UserRole.ADMIN.equals(role) ?
resolveAdminPermissions(orgs) :
resolveUserPermissions(user, orgs);
}
示例9: resolveAdminPermissions
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
/**
* Returns permissions for specified organizations for administrator user. By default
* administrators have access to every organization.
*
* @param orgs organizations
* @return permissions
*/
private Collection<CcOrgPermission> resolveAdminPermissions(Collection<UUID> orgs) {
return ccClient.getOrgs()
// filter organizations if at least one was specified, otherwise accept all
.filter(org -> orgs.contains(org.getGuid()) || orgs.isEmpty())
// grant full access
.map(org -> new CcOrgPermission(org, true, true, true))
.toList().toBlocking().single();
}
示例10: getAccessibleOrgs
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
Collection<CcOrgPermission> getAccessibleOrgs(HttpServletRequest request)
throws IOException, ServletException;
示例11: prepareAccessibleOrgList
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
private void prepareAccessibleOrgList(CcOrgPermission toBePlacedInList) throws IOException, ServletException {
Collection<CcOrgPermission> accessibleOrgs = new ArrayList<>();
accessibleOrgs.add(toBePlacedInList);
when(authorization.getAccessibleOrgs(any())).thenReturn(accessibleOrgs);
}
示例12: noOrgsAccessible
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
private void noOrgsAccessible() throws IOException, ServletException {
Collection<CcOrgPermission> accessibleOrgs = new ArrayList<>();
when(authorization.getAccessibleOrgs(any())).thenReturn(accessibleOrgs);
}
示例13: resolveUserPermissions
import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //导入依赖的package包/类
/**
* Return permissions for specified organizations for regular user.
*
* @param user user GUID
* @param orgs organizations
* @return permissions
*/
private Collection<CcOrgPermission> resolveUserPermissions(UUID user, Collection<UUID> orgs) {
return ccClient.getUserPermissions(user, orgs);
}