当前位置: 首页>>代码示例>>Java>>正文


Java RegistryException类代码示例

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


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

示例1: createRegistryService

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
private void createRegistryService(Class realClass, WithRegistry withRegistry) {
    try {
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(withRegistry.tenantDomain());
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(withRegistry.tenantId());
        RegistryContext registryContext = RegistryContext.getBaseInstance(IdentityTenantUtil.getRealmService());
        DataSource dataSource = MockInitialContextFactory
                .initializeDatasource(REG_DB_JNDI_NAME, realClass, new String[] { REG_DB_SQL_FILE });
        registryContext.setDataAccessManager(new JDBCDataAccessManager(dataSource));
        RegistryService registryService = new EmbeddedRegistryService(registryContext);

        OSGiDataHolder.getInstance().setRegistryService(registryService);
        PrivilegedCarbonContext.getThreadLocalCarbonContext()
                .setRegistry(RegistryType.USER_GOVERNANCE, registryService.getRegistry());
        Class[] singletonClasses = withRegistry.injectToSingletons();
        injectSingletonVariables(registryService, RegistryService.class, singletonClasses);
    } catch (RegistryException e) {
        log.error("Error creating the registry.", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:CarbonBasedTestListener.java

示例2: getChildResources

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
/**
 * This helps to find resources un a recursive manner
 *
 * @param node           attribute value node
 * @param parentResource parent resource Name
 * @return child resource set
 * @throws RegistryException throws
 */
private EntitlementTreeNodeDTO getChildResources(EntitlementTreeNodeDTO node,
                                                 String parentResource) throws RegistryException {

    if (registry.resourceExists(parentResource)) {
        String[] resourcePath = parentResource.split("/");
        EntitlementTreeNodeDTO childNode =
                new EntitlementTreeNodeDTO(resourcePath[resourcePath.length - 1]);
        node.addChildNode(childNode);
        Resource root = registry.get(parentResource);
        if (root instanceof Collection) {
            Collection collection = (Collection) root;
            String[] resources = collection.getChildren();
            for (String resource : resources) {
                getChildResources(childNode, resource);
            }
        }
    }
    return node;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:CarbonEntitlementDataFinder.java

示例3: getPolicy

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
/**
 * This returns given policy as Registry resource
 *
 * @param policyId   policy id
 * @param collection
 * @return policy as Registry resource
 * @throws EntitlementException throws, if fails
 */
public Resource getPolicy(String policyId, String collection) throws EntitlementException {
    String path = null;

    if (log.isDebugEnabled()) {
        log.debug("Retrieving entitlement policy");
    }

    try {
        path = collection + policyId;

        if (!registry.resourceExists(path)) {
            if (log.isDebugEnabled()) {
                log.debug("Trying to access an entitlement policy which does not exist");
            }
            return null;
        }
        return registry.get(path);
    } catch (RegistryException e) {
        log.error("Error while retrieving entitlement policy " + policyId + " PAP policy store", e);
        throw new EntitlementException("Error while retrieving entitlement policy " + policyId
                                       + " PAP policy store");
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:32,代码来源:PAPPolicyStore.java

示例4: removePolicy

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
/**
 * @param policyId
 * @throws EntitlementException
 */
public void removePolicy(String policyId) throws EntitlementException {
    String path = null;

    if (log.isDebugEnabled()) {
        log.debug("Removing entitlement policy");
    }

    try {
        path = PDPConstants.ENTITLEMENT_POLICY_PAP + policyId;
        if (!registry.resourceExists(path)) {
            if (log.isDebugEnabled()) {
                log.debug("Trying to access an entitlement policy which does not exist");
            }
            return;
        }
        registry.delete(path);
    } catch (RegistryException e) {
        log.error("Error while removing entitlement policy " + policyId + " from PAP policy store", e);
        throw new EntitlementException("Error while removing policy " + policyId + " from PAP policy store");
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:PAPPolicyStore.java

示例5: deleteSubscriber

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
public void deleteSubscriber(String subscriberId) throws EntitlementException {

        String subscriberPath;

        if (subscriberId == null) {
            log.error("Subscriber Id can not be null");
            throw new EntitlementException("Subscriber Id can not be null");
        }

        if (EntitlementConstants.PDP_SUBSCRIBER_ID.equals(subscriberId.trim())) {
            log.error("Can not delete PDP publisher");
            throw new EntitlementException("Can not delete PDP publisher");
        }

        try {
            subscriberPath = PDPConstants.ENTITLEMENT_POLICY_PUBLISHER +
                    RegistryConstants.PATH_SEPARATOR + subscriberId;

            if (registry.resourceExists(subscriberPath)) {
                registry.delete(subscriberPath);
            }
        } catch (RegistryException e) {
            log.error("Error while deleting subscriber details", e);
            throw new EntitlementException("Error while deleting subscriber details", e);
        }
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:PolicyPublisher.java

示例6: retrieveSubscriber

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
public PublisherDataHolder retrieveSubscriber(String id, boolean returnSecrets) throws EntitlementException {

        try {
            if (registry.resourceExists(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER +
                    RegistryConstants.PATH_SEPARATOR + id)) {
                Resource resource = registry.get(PDPConstants.ENTITLEMENT_POLICY_PUBLISHER +
                        RegistryConstants.PATH_SEPARATOR + id);

                return new PublisherDataHolder(resource, returnSecrets);
            }
        } catch (RegistryException e) {
            log.error("Error while retrieving subscriber detail of id : " + id, e);
            throw new EntitlementException("Error while retrieving subscriber detail of id : " + id, e);
        }

        throw new EntitlementException("No Subscriber is defined for given Id");
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:18,代码来源:PolicyPublisher.java

示例7: getPolicyResource

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
/**
 * This returns given policy as Registry resource
 *
 * @param policyId policy id
 * @return policy as Registry resource
 * @throws EntitlementException throws, if fails
 */
private Resource getPolicyResource(String policyId) throws EntitlementException {
    String path = null;

    if (log.isDebugEnabled()) {
        log.debug("Retrieving entitlement policy");
    }

    try {
        path = policyStorePath + policyId;

        if (!registry.resourceExists(path)) {
            if (log.isDebugEnabled()) {
                log.debug("Trying to access an entitlement policy which does not exist");
            }
            return null;
        }
        return registry.get(path);
    } catch (RegistryException e) {
        log.error("Error while retrieving entitlement policy : " + policyId, e);
        throw new EntitlementException("Error while retrieving entitlement policy : " + policyId, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:30,代码来源:RegistryPolicyReader.java

示例8: isPolicyExist

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的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

示例9: deletePolicy

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的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

示例10: addKeystores

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的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

示例11: getIdentityResource

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的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

示例12: putIdentityResource

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的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

示例13: getServiceProviders

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
public SAMLSSOServiceProviderDO[] getServiceProviders() throws IdentityException {
    SAMLSSOServiceProviderDO[] serviceProvidersList = new SAMLSSOServiceProviderDO[0];
    try {
        if (registry.resourceExists(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)) {
            String[] providers = (String[]) registry.get(
                    IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS).getContent();
            if (providers != null) {
                serviceProvidersList = new SAMLSSOServiceProviderDO[providers.length];
                for (int i = 0; i < providers.length; i++) {
                    serviceProvidersList[i] = resourceToObject(registry.get(providers[i]));
                }
            }
        }
    } catch (RegistryException e) {
        log.error("Error reading Service Providers from Registry", e);
        throw IdentityException.error("Error reading Service Providers from Registry", e);
    }
    return serviceProvidersList;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:20,代码来源:SAMLSSOServiceProviderDAO.java

示例14: getXmppSettings

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
/**
 * retrieve XMPP Settings of a user by providing the userId
 *
 * @param userId
 * @return
 */
public XMPPSettingsDO getXmppSettings(String userId) {

    XMPPSettingsDO xmppSettings = null;

    try {
        if (registry.resourceExists(IdentityRegistryResources.XMPP_SETTINGS_ROOT + userId)) {
            xmppSettings = resourceToObject(registry
                    .get(IdentityRegistryResources.XMPP_SETTINGS_ROOT + userId));
        }

    } catch (RegistryException e) {
        log.error("Cannot retrieve the XMPP Settings for the user " + userId, e);
    }
    return xmppSettings;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:XMPPSettingsDAO.java

示例15: isXmppSettingsEnabled

import org.wso2.carbon.registry.core.exceptions.RegistryException; //导入依赖的package包/类
/**
 * Checks whether the given user has enabled XMPP based multifactor auth.
 *
 * @param userId
 * @return
 */
public boolean isXmppSettingsEnabled(String userId) {

    boolean isEnabled = false;
    XMPPSettingsDO xmppSettings;
    try {
        if (registry.resourceExists(IdentityRegistryResources.XMPP_SETTINGS_ROOT + userId)) {
            xmppSettings = resourceToObject(registry
                    .get(IdentityRegistryResources.XMPP_SETTINGS_ROOT + userId));
            isEnabled = xmppSettings.isXmppEnabled();
        }
    } catch (RegistryException e) {
        log.error("Error when checking the availability of the user " + userId, e);
    }

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


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