private static void permissionPath(Registry tenantGovReg, String permissionPath) throws RegistryException { Collection appCollection = (Collection) tenantGovReg.get(permissionPath); String[] childern = appCollection.getChildren(); if (childern == null || childern.length == 0) { paths.add(permissionPath.replace(applicationNode, "").substring(2)); } while (childern != null && childern.length != 0) { for (int i = 0; i < childern.length; i++) { permissionPath(tenantGovReg, childern[i]); } break; } }
private static void permissionPath(Registry tenantGovReg, String permissionPath, List<String> paths, String applicationNode) throws RegistryException { Collection appCollection = (Collection) tenantGovReg.get(permissionPath); String[] childern = appCollection.getChildren(); if (childern == null || childern.length == 0) { paths.add(permissionPath.replace(applicationNode, "").substring(2)); } while (childern != null && childern.length != 0) { for (int i = 0; i < childern.length; i++) { permissionPath(tenantGovReg, childern[i], paths, applicationNode); } break; } }
@Override public String[] getVersions(String policyId) throws EntitlementException { List<String> versions = new ArrayList<String>(); Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); Collection collection = null; try { try { collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); } catch (ResourceNotFoundException e) { // ignore } if (collection != null && collection.getChildren() != null) { String[] children = collection.getChildren(); for (String child : children) { versions.add(RegistryUtils.getResourceName(child)); } } } catch (RegistryException e) { log.error("Error while creating new version of policy", e); } return versions.toArray(new String[versions.size()]); } }
@Override public String[] getVersions(String policyId) throws EntitlementException { List<String> versions = new ArrayList<String>(); Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); Collection collection = null; try { try { collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); } catch (ResourceNotFoundException e) { // ignore } if (collection != null && collection.getChildren() != null) { String[] children = collection.getChildren(); for (String child : children) { versions.add(RegistryUtils.getResourceName(child)); } } } catch (RegistryException e) { log.error("Error while creating new version of policy", e); } return versions.toArray(new String[versions.size()]); } }
@Override public String[] getVersions(String policyId) throws EntitlementException { List<String> versions = new ArrayList<String>(); Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); Collection collection = null; try { try { collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); } catch (ResourceNotFoundException e) { // ignore } if (collection != null && collection.getChildren() != null) { String[] children = collection.getChildren(); for (String child : children) { versions.add(RegistryUtils.getResourceName(child)); } } } catch (RegistryException e) { log.error("Error while creating new version of policy", e); } return versions.toArray(new String[versions.size()]); } }
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode, Registry registry, Registry tenantRegistry) throws RegistryException, UserStoreException { String[] children = parent.getChildren(); UIPermissionNode[] childNodes = new UIPermissionNode[children.length]; for (int i = 0; i < children.length; i++) { String child = children[i]; Resource resource = null; if (registry.resourceExists(child)) { resource = registry.get(child); } else if (tenantRegistry != null) { resource = tenantRegistry.get(child); } else { throw new RegistryException("Permission resource not found in the registry."); } childNodes[i] = getUIPermissionNode(resource, true); if (resource instanceof Collection) { buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry, tenantRegistry); } } parentNode.setNodeList(childNodes); }
/** * * Populates the properties using the configuration file in the given registry location. * * @param configResourcePath * @param registry */ public void populate(String configResourcePath, Registry registry){ try{ if(registry.resourceExists(configResourcePath)) { Resource configurationsResource = registry.get(configResourcePath); StAXOMBuilder builder = new StAXOMBuilder(configurationsResource.getContentStream()); OMElement root = builder.getDocumentElement(); populate(root); } } catch (XMLStreamException e) { String errorMessage = "Can't load the tenant configuration for the tenant " + tenantID; log.error(errorMessage, e); } catch (RegistryException e) { String errorMessage = "Can't load the tenant configuration for the tenant " + tenantID; log.error(errorMessage, e); } }
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode, Registry registry, Registry tenantRegistry) throws RegistryException, UserStoreException { String[] children = parent.getChildren(); UIPermissionNode[] childNodes = new UIPermissionNode[children.length]; for (int i = 0; i < children.length; i++) { String child = children[i]; Resource resource = null; if (registry.resourceExists(child)) { resource = registry.get(child); } else if (tenantRegistry != null) { resource = tenantRegistry.get(child); } else { throw new RegistryException("Permission resource not found in the registry."); } childNodes[i] = getUIPermissionNode(resource, true); if (resource instanceof Collection) { buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry, tenantRegistry); } } parentNode.setNodeList(childNodes); }
try { org.wso2.carbon.registry.api.Resource resource = registry. get(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER_VERIFICATION + verificationCode); List<String> list = resource.getPropertyValues("subscriberIds"); if (list != null) {
try { org.wso2.carbon.registry.api.Resource resource = registry. get(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER_VERIFICATION + verificationCode); List<String> list = resource.getPropertyValues("subscriberIds"); if (list != null) {
try { org.wso2.carbon.registry.api.Resource resource = registry. get(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER_VERIFICATION + verificationCode); List<String> list = resource.getPropertyValues("subscriberIds"); if (list != null) {
/** * Load Analytics profile from given registry and registry path. * * @param analyticsServerProfile AnalyticsServerProfile instance * @param registry Registry space where file is located * @param location Registry path of the profile file */ private void loadAnalyticsProfileFromRegistry(AnalyticsServerProfile analyticsServerProfile, Registry registry, String location) { try { if (registry.resourceExists(location)) { Resource resource = registry.get(location); String resourceContent = new String((byte[]) resource.getContent()); parseAnalyticsProfile(resourceContent, analyticsServerProfile); } else { String errMsg = "The resource: " + location + " does not exist."; handleError(errMsg); } } catch (RegistryException e) { String errMsg = "Error occurred while reading the resource from registry: " + location + " to build the Analytics server profile: " + profileLocation; handleError(errMsg, e); } }
@Override public PolicyDTO getPolicy(String policyId, String version) throws EntitlementException { // Zero means current version if (version == null || version.trim().length() == 0) { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { Collection collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); if (collection != null) { version = collection.getProperty("version"); } } catch (RegistryException e) { log.error(e); throw new EntitlementException("Invalid policy version"); } } PAPPolicyStore policyStore = new PAPPolicyStore(); PAPPolicyStoreReader reader = new PAPPolicyStoreReader(policyStore); Resource resource = policyStore.getPolicy(version, PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId + RegistryConstants.PATH_SEPARATOR); if (resource == null) { throw new EntitlementException("Invalid policy version"); } return reader.readPolicyDTO(resource); }
@Override public PolicyDTO getPolicy(String policyId, String version) throws EntitlementException { // Zero means current version if (version == null || version.trim().length() == 0) { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { Collection collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); if (collection != null) { version = collection.getProperty("version"); } } catch (RegistryException e) { log.error(e); throw new EntitlementException("Invalid policy version"); } } PAPPolicyStore policyStore = new PAPPolicyStore(); PAPPolicyStoreReader reader = new PAPPolicyStoreReader(policyStore); Resource resource = policyStore.getPolicy(version, PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId + RegistryConstants.PATH_SEPARATOR); if (resource == null) { throw new EntitlementException("Invalid policy version"); } return reader.readPolicyDTO(resource); }
@Override public PolicyDTO getPolicy(String policyId, String version) throws EntitlementException { // Zero means current version if (version == null || version.trim().length() == 0) { Registry registry = EntitlementServiceComponent. getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId()); try { Collection collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId); if (collection != null) { version = collection.getProperty("version"); } } catch (RegistryException e) { log.error(e); throw new EntitlementException("Invalid policy version"); } } PAPPolicyStore policyStore = new PAPPolicyStore(); PAPPolicyStoreReader reader = new PAPPolicyStoreReader(policyStore); Resource resource = policyStore.getPolicy(version, PDPConstants.ENTITLEMENT_POLICY_VERSION + policyId + RegistryConstants.PATH_SEPARATOR); if (resource == null) { throw new EntitlementException("Invalid policy version"); } return reader.readPolicyDTO(resource); }
Registry registry = UserMgtDSComponent.getRegistryService().getGovernanceSystemRegistry(); if (tenantId == MultitenantConstants.SUPER_TENANT_ID) { regRoot = (Collection) registry.get(UserMgtConstants.UI_PERMISSION_ROOT); String displayName = regRoot.getProperty(UserMgtConstants.DISPLAY_NAME); nodeRoot = new UIPermissionNode(UserMgtConstants.UI_PERMISSION_ROOT, displayName); } else { regRoot = (Collection) registry.get(UserMgtConstants.UI_ADMIN_PERMISSION_ROOT); appRoot = (Collection) tenentRegistry.get(APPLICATIONS_PATH); parent = (Collection) tenentRegistry.newCollection(); parent.setProperty(UserMgtConstants.DISPLAY_NAME, "All Permissions");
try { collection = (Collection) registry. get(PDPConstants.ENTITLEMENT_POLICY_VERSION + policyDTO.getPolicyId()); } catch (ResourceNotFoundException e) {
Collection appNodeCollec = (Collection) tenantGovReg.get(applicationNode); String[] childern = appNodeCollec.getChildren();