當前位置: 首頁>>代碼示例>>Java>>正文


Java CcOrgPermission類代碼示例

本文整理匯總了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());
}
 
開發者ID:trustedanalytics,項目名稱:data-acquisition,代碼行數:20,代碼來源:PlatformAuthorization.java

示例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));

}
 
開發者ID:trustedanalytics,項目名稱:data-acquisition,代碼行數:18,代碼來源:DASIT.java

示例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);
}
 
開發者ID:trustedanalytics,項目名稱:user-management,代碼行數:21,代碼來源:AuthorizationController.java

示例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());
    }
}
 
開發者ID:trustedanalytics,項目名稱:user-management,代碼行數:27,代碼來源:OrgsIT.java

示例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;
}
 
開發者ID:trustedanalytics,項目名稱:cf-client,代碼行數:22,代碼來源:FeignClient.java

示例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;
    }
 
開發者ID:trustedanalytics,項目名稱:cf-client,代碼行數:22,代碼來源:CcClient.java

示例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.
}
 
開發者ID:trustedanalytics,項目名稱:data-acquisition,代碼行數:30,代碼來源:DASIT.java

示例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);
}
 
開發者ID:trustedanalytics,項目名稱:user-management,代碼行數:18,代碼來源:AuthorizationController.java

示例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();
}
 
開發者ID:trustedanalytics,項目名稱:user-management,代碼行數:16,代碼來源:AuthorizationController.java

示例10: getAccessibleOrgs

import org.trustedanalytics.cloud.cc.api.CcOrgPermission; //導入依賴的package包/類
Collection<CcOrgPermission> getAccessibleOrgs(HttpServletRequest request)
throws IOException, ServletException;
 
開發者ID:trustedanalytics,項目名稱:data-acquisition,代碼行數:3,代碼來源:Authorization.java

示例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);
}
 
開發者ID:trustedanalytics,項目名稱:data-acquisition,代碼行數:6,代碼來源:DASIT.java

示例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);
}
 
開發者ID:trustedanalytics,項目名稱:data-acquisition,代碼行數:5,代碼來源:DASIT.java

示例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);
}
 
開發者ID:trustedanalytics,項目名稱:user-management,代碼行數:11,代碼來源:AuthorizationController.java


注:本文中的org.trustedanalytics.cloud.cc.api.CcOrgPermission類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。