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


Java Resource类代码示例

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


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

示例1: getPolicy

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

示例2: retrieveSubscriber

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

示例3: getPolicyResource

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

示例4: removeTrustedService

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

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

示例9: putIdentityResource

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

示例10: getOAuthConsumerSecret

import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
/**
 * Returns oAuth consumer secret for a give consumer key.
 *
 * @param consumerKey consumer key
 * @return oAuth consumer secret
 * @throws IdentityException if error occurs while obtaining the consumer secret
 */
public String getOAuthConsumerSecret(String consumerKey) throws IdentityException {
    String path = null;
    Resource resource = null;

    if (log.isDebugEnabled()) {
        log.debug("Retreiving user for OAuth consumer key  " + consumerKey);
    }

    try {
        path = RegistryConstants.PROFILES_PATH + consumerKey;
        if (registry.resourceExists(path)) {
            resource = registry.get(path);
            return resource.getProperty(IdentityRegistryResources.OAUTH_CONSUMER_PATH);
        } else {
            return null;
        }
    } catch (RegistryException e) {
        log.error("Error while retreiving user for OAuth consumer key  " + consumerKey, e);
        throw IdentityException.error("Error while retreiving user for OAuth consumer key  "
                + consumerKey, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:30,代码来源:OAuthConsumerDAO.java

示例11: getOpenIDAdminDO

import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
/**
 * Retrieve OpenID admin for a tenant.
 *
 * @return open id admin of the tenant
 * @throws IdentityException if error occurs while retrieving the OpenID admin
 */
public OpenIDAdminDO getOpenIDAdminDO() throws IdentityException {
    OpenIDAdminDO opdo = null;
    Resource resource = null;

    if (log.isDebugEnabled()) {
        log.debug("Retrieving OpenID admin for tenant");
    }
    try {
        if (registry.resourceExists(IdentityRegistryResources.OPEN_ID_ADMIN_SETTINGS)) {
            resource = registry.get(IdentityRegistryResources.OPEN_ID_ADMIN_SETTINGS);
            return resourceToObject(resource);
        }
    } catch (RegistryException e) {
        log.error("Error while retreiving openid admin", e);
        throw IdentityException.error("Error while retreiving openid admin", e);
    }
    return opdo;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:OpenIDAdminDAO.java

示例12: getParameter

import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
/**
 * @param paramName
 * @return
 * @throws IdentityException
 */
public ParameterDO getParameter(String paramName) throws IdentityException {
    ParameterDO param = null;
    String path = null;
    Resource resource = null;

    if (log.isDebugEnabled()) {
        log.debug("Retrieving parameter " + paramName);
    }

    try {
        path = IdentityRegistryResources.CARD_ISSUER;
        param = new ParameterDO();
        if (registry.resourceExists(path)) {
            resource = registry.get(path);
            if (resource != null) {
                param.setName(paramName);
                param.setValue(resource.getProperty(paramName));
            }
        }
    } catch (RegistryException e) {
        log.error("Error while retrieving parameter " + paramName, e);
        throw IdentityException.error("Error while retrieving parameter " + paramName, e);
    }
    return param;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:31,代码来源:ParameterDAO.java

示例13: removeParameter

import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
/**
 * @param parameterDO
 * @throws IdentityException
 */
public void removeParameter(ParameterDO parameterDO) throws IdentityException {
    String path = null;
    Resource resource = null;

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

    try {
        path = IdentityRegistryResources.CARD_ISSUER;
        if (registry.resourceExists(path)) {
            resource = registry.get(path);
            if (resource != null) {
                resource.removeProperty(parameterDO.getName());
                registry.put(path, resource);
            }
        }
    } catch (RegistryException e) {
        log.error("Error while removing parameter", e);
        throw IdentityException.error("Error while removing parameter", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:ParameterDAO.java

示例14: testGetServiceProviders

import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
@Test
public void testGetServiceProviders() throws Exception {
    when(mockRegistry.resourceExists(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)).thenReturn(true);
    Resource collection = new CollectionImpl();
    String[] paths = new String[]{
            getPath("DummyIssuer"), getPath("DummyAdvIssuer")
    };
    Properties dummyResourceProperties = new Properties();
    dummyResourceProperties.putAll(dummyBasicProperties);
    Resource dummyResource = new ResourceImpl();
    dummyResource.setProperties(dummyResourceProperties);

    Properties dummyAdvProperties = new Properties();
    dummyAdvProperties.putAll((Map<?, ?>) dummyAdvProperties);
    Resource dummyAdvResource = new ResourceImpl();
    dummyAdvResource.setProperties(dummyAdvProperties);
    Resource[] spResources = new Resource[]{dummyResource, dummyAdvResource};
    collection.setContent(paths);
    when(mockRegistry.get(IdentityRegistryResources.SAML_SSO_SERVICE_PROVIDERS)).thenReturn(collection);
    when(mockRegistry.get(paths[0])).thenReturn(spResources[0]);
    when(mockRegistry.get(paths[1])).thenReturn(spResources[1]);
    SAMLSSOServiceProviderDO[] serviceProviders = objUnderTest.getServiceProviders();
    assertEquals(serviceProviders.length, 2, "Should have returned 2 service providers.");
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:SAMLSSOServiceProviderDAOTest.java

示例15: testGetServiceProvider

import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
@Test
public void testGetServiceProvider() throws Exception {
    mockStatic(IdentityTenantUtil.class);
    RealmService mockRealmService = mock(RealmService.class);
    TenantManager mockTenantManager = mock(TenantManager.class);
    when(IdentityTenantUtil.getRealmService()).thenReturn(mockRealmService);
    when(mockRealmService.getTenantManager()).thenReturn(mockTenantManager);
    when(mockTenantManager.getDomain(anyInt())).thenReturn("test.com");

    Properties dummyResourceProperties = new Properties();
    dummyResourceProperties.putAll(dummyBasicProperties);
    Resource dummyResource = new ResourceImpl();
    dummyResource.setProperties(dummyResourceProperties);

    String path = getPath(dummyResource.getProperty(IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
    when(mockRegistry.resourceExists(path)).thenReturn(true);
    when(mockRegistry.get(path)).thenReturn(dummyResource);

    SAMLSSOServiceProviderDO serviceProviderDO = objUnderTest.getServiceProvider(dummyResource.getProperty
            (IdentityRegistryResources.PROP_SAML_SSO_ISSUER));
    assertEquals(serviceProviderDO.getTenantDomain(), "test.com", "Retrieved resource's tenant domain mismatch");
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:SAMLSSOServiceProviderDAOTest.java


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