• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Registry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.wso2.carbon.registry.core.Registry的典型用法代码示例。如果您正苦于以下问题:Java Registry类的具体用法?Java Registry怎么用?Java Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Registry类属于org.wso2.carbon.registry.core包,在下文中一共展示了Registry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addSamplePolicies

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
public static void addSamplePolicies(Registry registry) {

        File policyFolder = new File(CarbonUtils.getCarbonHome() + File.separator
                + "repository" + File.separator + "resources" + File.separator
                + "identity" + File.separator + "policies" + File.separator + "xacml"
                + File.separator + "default");

        File[] fileList;
        if (policyFolder.exists() && ArrayUtils.isNotEmpty(fileList = policyFolder.listFiles())) {
            for (File policyFile : fileList) {
                if (policyFile.isFile()) {
                    PolicyDTO policyDTO = new PolicyDTO();
                    try {
                        policyDTO.setPolicy(FileUtils.readFileToString(policyFile));
                        EntitlementUtil.addFilesystemPolicy(policyDTO, registry, false);
                    } catch (Exception e) {
                        // log and ignore
                        log.error("Error while adding sample XACML policies", e);
                    }
                }
            }
        }
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:EntitlementUtil.java


示例2: isPolicyExist

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
@Override
public boolean isPolicyExist(String policyId) {

    Registry registry;
    String policyPath;
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();

    if (policyId == null || policyId.trim().length() == 0) {
        return false;
    }

    try {
        registry = EntitlementServiceComponent.getRegistryService().
                getGovernanceSystemRegistry(tenantId);

        policyPath = policyStorePath + policyId;
        return registry.resourceExists(policyPath);
    } catch (RegistryException e) {
        //ignore
        return false;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:RegistryPolicyStoreManageModule.java


示例3: deletePolicy

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
@Override
public boolean deletePolicy(String policyIdentifier) {

    Registry registry;
    String policyPath;
    int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();

    if (policyIdentifier == null || policyIdentifier.trim().length() == 0) {
        return false;
    }

    try {
        registry = EntitlementServiceComponent.getRegistryService().
                getGovernanceSystemRegistry(tenantId);

        policyPath = policyStorePath + policyIdentifier;
        registry.delete(policyPath);
        return true;
    } catch (RegistryException e) {
        log.error(e);
        return false;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:RegistryPolicyStoreManageModule.java


示例4: removeTrustedService

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
/**
 * Remove trusted service
 *
 * @param groupName      Group name
 * @param serviceName    Service name
 * @param trustedService Trusted service name
 * @throws org.wso2.carbon.registry.api.RegistryException
 */
private void removeTrustedService(String groupName, String serviceName,
                                  String trustedService) throws RegistryException {

    String resourcePath = RegistryResources.SERVICE_GROUPS + groupName +
                RegistryResources.SERVICES + serviceName + "/trustedServices";
    Registry registry = getConfigSystemRegistry();
    if (registry != null) {
        if (registry.resourceExists(resourcePath)) {
            Resource resource = registry.get(resourcePath);
            if (resource.getProperty(trustedService) != null) {
                resource.removeProperty(trustedService);
            }
            registry.put(resourcePath, resource);
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:ApplicationManagementServiceImpl.java


示例5: getUrl

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
public static String getUrl() throws Exception {

        if (url == null) {
            ServiceHolder serviceHodler = ServiceHolder.getInstance();
            RegistryService regService = serviceHodler.getRegistryService();
            Registry systemRegistry = regService.getConfigSystemRegistry();
            Resource resource = systemRegistry.get("/carbon/connection/props");
            String servicePath = resource.getProperty("service-path");
            String contextRoot = resource.getProperty("context-root");

            String host = resource.getProperty("host-name");
            contextRoot = StringUtils.equals("/", contextRoot) ? "" : contextRoot;

            host = (host == null) ? "localhost" : host;
            String port = System.getProperty("carbon.https.port");
            StringBuilder urlValue = new StringBuilder();
            url = (urlValue.append("https://").append(host).append(":").append(port).append("/").append(contextRoot).append(servicePath).append("/")).toString();
        }

        return url;
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:SecurityUIUtil.java


示例6: addKeystores

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
private void addKeystores() throws RegistryException {
    Registry registry = SecurityServiceHolder.getRegistryService().getGovernanceSystemRegistry();
    try {
        boolean transactionStarted = Transaction.isStarted();
        if (!transactionStarted) {
            registry.beginTransaction();
        }
        if (!registry.resourceExists(SecurityConstants.KEY_STORES)) {
            Collection kstores = registry.newCollection();
            registry.put(SecurityConstants.KEY_STORES, kstores);

            Resource primResource = registry.newResource();
            if (!registry.resourceExists(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
                registry.put(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE,
                        primResource);
            }
        }
        if (!transactionStarted) {
            registry.commitTransaction();
        }
    } catch (Exception e) {
        registry.rollbackTransaction();
        throw e;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:SecurityDeploymentInterceptor.java


示例7: removeTrustedService

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
private void removeTrustedService(String groupName, String serviceName, String trustedService)
        throws SecurityConfigException {
    Registry registry;
    String resourcePath;
    Resource resource;
    try {
        resourcePath = RegistryResources.SERVICE_GROUPS + groupName
                + RegistryResources.SERVICES + serviceName + "/trustedServices";
        registry = getConfigSystemRegistry(); //TODO: Multitenancy
        if (registry != null && registry.resourceExists(resourcePath)) {
            resource = registry.get(resourcePath);
            if (resource.getProperty(trustedService) != null) {
                resource.removeProperty(trustedService);
            }
            registry.put(resourcePath, resource);
        }
    } catch (Exception e) {
        log.error("Error occured while removing trusted service for STS", e);
        throw new SecurityConfigException("Error occured while adding trusted service for STS",
                e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:STSAdminServiceImpl.java


示例8: createOrUpdateParameter

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
/**
 * @param registry
 * @param paramName
 * @param value
 * @throws IdentityException
 */
public void createOrUpdateParameter(Registry registry, String paramName, String value)
        throws IdentityException {

    if (paramName == null || value == null) {
        throw IdentityException.error("Invalid inputs");
    }

    ParameterDO param = null;
    param = new ParameterDO();
    paramName = paramName.trim();
    param.setName(paramName);

    param.setValue(value);

    ParameterDAO dao = new ParameterDAO(registry);
    dao.createOrUpdateParameter(param);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:IdentityPersistenceManager.java


示例9: getIdentityResource

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
@Override
public Resource getIdentityResource(String path,
                                    String tenantDomain) throws IdentityRuntimeException {
    startTenantFlow(tenantDomain);
    try {
        Registry registry = getRegistryForTenant(tenantDomain);
        Resource resource = null;

        if (registry.resourceExists(path)) {
            resource = registry.get(path);
        }
        return resource;
    } catch (RegistryException e) {
        String errorMsg = String.format(ERROR_GET_RESOURCE, path, tenantDomain);
        throw IdentityRuntimeException.error(errorMsg, e);
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:RegistryResourceMgtServiceImpl.java


示例10: putIdentityResource

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
@Override
public void putIdentityResource(Resource identityResource,
                                String path,
                                String tenantDomain) throws IdentityRuntimeException {
    startTenantFlow(tenantDomain);
    try {
        Registry registry = getRegistryForTenant(tenantDomain);
        registry.put(path, identityResource);
        if (log.isDebugEnabled()) {
            log.debug(String.format(MSG_RESOURCE_PERSIST, path, tenantDomain));
        }
    } catch (RegistryException e) {
        String errorMsg = String.format(ERROR_PERSIST_RESOURCE, tenantDomain, path);
        throw IdentityRuntimeException.error(errorMsg, e);
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:19,代码来源:RegistryResourceMgtServiceImpl.java


示例11: getRegistry

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
public static Registry getRegistry(String domainName, String username) throws IdentityException {
    HttpSession httpSess = getHttpSession();

    if (httpSess != null) {
        if (httpSess.getAttribute(ServerConstants.USER_LOGGED_IN) != null) {
            try {
                return AdminServicesUtil.getSystemRegistry();
            } catch (CarbonException e) {
                log.error("Error obtaining a registry instance", e);
                throw IdentityException.error(
                        "Error obtaining a registry instance", e);
            }
        }
    }
    return getRegistryForAnonymousSession(domainName, username);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:17,代码来源:IdentityTenantUtil.java


示例12: getRegistryForAnonymousSession

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static Registry getRegistryForAnonymousSession(String domainName, String username)
        throws IdentityException {
    try {
        if (domainName == null && username == null) {
            domainName = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
        }
        if (username == null) {
            return AnonymousSessionUtil.getSystemRegistryByDomainName(registryService,
                    realmService, domainName);
        } else {
            return AnonymousSessionUtil.getSystemRegistryByUserName(registryService,
                    realmService, username);
        }
    } catch (CarbonException e) {
        log.error("Error obtaining a registry instance", e);
        throw IdentityException.error("Error obtaining a registry instance", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:IdentityTenantUtil.java


示例13: deleteOldResourcesIfFound

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
private void deleteOldResourcesIfFound(Registry registry, String userName, String secretKeyPath) {

        boolean useRegistryIndexing = Boolean.parseBoolean(IdentityMgtConfig.getInstance().getProperty
                (REGISTRY_INDEXING_ENABLED));
        if (useRegistryIndexing && RegistryConfigLoader.getInstance().IsStartIndexing()) {

            if (log.isDebugEnabled()) {
                log.debug("Property: " + REGISTRY_INDEXING_ENABLED + " is enabled. Switching to registry search mode " +
                        "" + "to delete old confirmation codes.");
            }
            deleteOldConfirmationCodesByRegistrySearch(registry, userName, secretKeyPath);

        } else {

            if (log.isDebugEnabled()) {
                log.debug("Deleting old confirmation codes iterating over registry resource collection at: " +
                        secretKeyPath);
            }
            deleteOldConfirmationCodesByResourceIteration(registry, userName, secretKeyPath);
        }
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:RegistryRecoveryDataStore.java


示例14: getConfigRegistryResourceContent

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
/**
 * Get the jwt details from the registry for tenants.
 *
 * @param tenantId         for identify tenant space.
 * @param registryLocation retrive the config file from tenant space.
 * @return the config for tenant
 * @throws RegistryException
 */
public static Resource getConfigRegistryResourceContent(int tenantId, final String registryLocation)
		throws RegistryException {
	try {
		Resource resource = null;
		PrivilegedCarbonContext.startTenantFlow();
		PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true);
		RegistryService registryService = JWTClientExtensionDataHolder.getInstance().getRegistryService();
		if (registryService != null) {
			Registry registry = registryService.getConfigSystemRegistry(tenantId);
			JWTClientUtil.loadTenantRegistry(tenantId);
			if (registry.resourceExists(registryLocation)) {
				resource = registry.get(registryLocation);
			}
		}
		return resource;
	} finally {
		PrivilegedCarbonContext.endTenantFlow();
	}
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:28,代码来源:JWTClientUtil.java


示例15: addJWTConfigResourceToRegistry

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
/**
 * Get the jwt details from the registry for tenants.
 *
 * @param tenantId for accesing tenant space.
 * @return the config for tenant
 * @throws RegistryException
 */
public static void addJWTConfigResourceToRegistry(int tenantId, String content)
		throws RegistryException {
	try {
		PrivilegedCarbonContext.startTenantFlow();
		PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId, true);
		RegistryService registryService = JWTClientExtensionDataHolder.getInstance().getRegistryService();
		if (registryService != null) {
			Registry registry = registryService.getConfigSystemRegistry(tenantId);
			JWTClientUtil.loadTenantRegistry(tenantId);
			if (!registry.resourceExists(TENANT_JWT_CONFIG_LOCATION)) {
				Resource resource = registry.newResource();
				resource.setContent(content.getBytes());
				registry.put(TENANT_JWT_CONFIG_LOCATION, resource);
			}
		}
	} finally {
		PrivilegedCarbonContext.endTenantFlow();
	}
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:27,代码来源:JWTClientUtil.java


示例16: find

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
/**
 * Search all meta data instances of this particular type with the given search attributes
 *
 * @param criteria Key value map that has search attributes
 * @return
 */
protected static List<Base> find(Registry registry, Map<String, String> criteria, String mt) throws MetadataException {
    BaseProvider provider = Util.getBaseProvider(mt);
    if (criteria != null && criteria.get(Constants.ATTRIBUTE_MEDIA_TYPE) == null) {
        criteria.put(Constants.ATTRIBUTE_MEDIA_TYPE, mt);
    }
    List<Base> baseResult = new ArrayList<Base>();
    try {
        ResourceData[] results = Util.getAttributeSearchService().search(criteria);
        for (ResourceData resourceData : results) {
            String path = RegistryUtils.getRelativePathToOriginal(resourceData.getResourcePath(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH);
            if (registry.resourceExists(path)) {
                Resource resource = registry.get(path);
                baseResult.add(provider.get(resource, registry));
            }
        }
    } catch (RegistryException e) {
        log.error(e.getMessage());
        throw new MetadataException(e.getMessage(), e);
    }
    return baseResult;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:28,代码来源:Base.java


示例17: deleteLifecycleHistoryFile

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
/**
 * This method deletes the lifecycle history file of a given artifact
 * @param artifactPath The resource path relative to governance registry
 * @param registry governace registry instance
 * @throws GovernanceException
 */
private static void deleteLifecycleHistoryFile(String artifactPath, Registry registry) throws GovernanceException {
    String artifactRootPath = RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + artifactPath;
    String historyResourcePath = GovernanceConstants.LIFECYCLE_HISTORY_PATH
                                 + artifactRootPath.replaceAll("/", "_");
    try {
        Registry govRegistry;
        if (registryService != null){
            int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
            govRegistry = registryService.getGovernanceSystemRegistry(tenantId);
        } else {
            //This will be used, when executing unit test cases.
            govRegistry =  registry;
        }
        if (govRegistry.resourceExists(historyResourcePath)) {
            govRegistry.delete(historyResourcePath);
        }
    } catch (RegistryException e) {
        String msg = "Error in deleting the the lifecycle history file at: " + historyResourcePath + ".";
        throw new GovernanceException(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:28,代码来源:GovernanceUtils.java


示例18: getArtifactDetailDiff

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
/**
 * This method is used to get a details difference of two resource while considering the media type.
 *
 * @param resourcePathOne   resource path one
 * @param resourcePathTwo   resource path two
 * @param mediaType         media type
 * @return                  Comparison object which includes the difference parameters.
 * @throws ComparisonException
 * @throws WSDLException
 * @throws RegistryException
 * @throws UnsupportedEncodingException
 */
public Comparison getArtifactDetailDiff(String resourcePathOne, String resourcePathTwo, String mediaType)
        throws ComparisonException, WSDLException, RegistryException, UnsupportedEncodingException {

    String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    Registry registry = RegistryCoreServiceComponent.getRegistryService().getRegistry(username, tenantId);
    Resource resourceOne = registry.get(resourcePathOne);
    Resource resourceTwo = registry.get(resourcePathTwo);

    switch (mediaType) {
    case ComparatorConstants.WSDL_MEDIA_TYPE:
        return getWSDLComparison(resourceOne, resourceTwo);
    default:
        return getArtifactTextDiff(resourcePathOne, resourcePathTwo);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:29,代码来源:ComparatorUtils.java


示例19: notify

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
protected void notify(RegistryEvent event, Registry registry, String path) throws Exception {
    try {
        if (EventDataHolder.getInstance().getRegistryNotificationService() == null) {
            log.debug("Eventing service is unavailable.");
            return;
        }
        if (registry == null || registry.getEventingServiceURL(path) == null) {
            EventDataHolder.getInstance().getRegistryNotificationService().notify(event);
            return;
        } else if (EventDataHolder.getInstance().getDefaultNotificationServiceURL() == null) {
            log.error("Governance Eventing Handler is not properly initialized");
        } else if (registry.getEventingServiceURL(path).equals(
                EventDataHolder.getInstance().getDefaultNotificationServiceURL())) {
            EventDataHolder.getInstance().getRegistryNotificationService().notify(event);
            return;
        } else {
            EventDataHolder.getInstance().getRegistryNotificationService()
                           .notify(event, registry.getEventingServiceURL(path));
            return;
        }
    } catch (RegistryException e) {
        log.error("Unable to send notification", e);
    }
    log.error("Unable to send notification");
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:26,代码来源:GovernanceEventingHandler.java


示例20: getRemoteRepository

import org.wso2.carbon.registry.core.Registry; //导入依赖的package包/类
private Repository getRemoteRepository(Map map) throws Exception {

        RemoteRegistry remoteRegistry;
        Registry registry; // an admin registry
        try {
            RemoteRegistryService remoteRegistryService = new RemoteRegistryService(
                    (String) map.get("registryURL"),
                    (String) map.get("userName"),
                    (String) map.get("password"));
            if (regRepo == null) {
                regRepo = new RegistryRepository(remoteRegistryService);
            }
        } catch (Exception e) {
            throw new Exception("Unable to create realm service " + e.getMessage());
        }
        return regRepo;
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:18,代码来源:RegistryRepositoryFactory.java



注:本文中的org.wso2.carbon.registry.core.Registry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MouseJoint类代码示例发布时间:2022-05-22
下一篇:
Java ContentInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap