本文整理汇总了Java中org.wso2.carbon.registry.core.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于org.wso2.carbon.registry.core包,在下文中一共展示了Resource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getVerifiedChallenges
import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
/**
* gets no of verified user challenges
*
* @param userDTO bean class that contains user and tenant Information
* @return no of verified challenges
* @throws IdentityException if fails
*/
public static int getVerifiedChallenges(UserDTO userDTO) throws IdentityException {
int noOfChallenges = 0;
try {
UserRegistry registry = IdentityMgtServiceComponent.getRegistryService().
getConfigSystemRegistry(MultitenantConstants.SUPER_TENANT_ID);
String identityKeyMgtPath = IdentityMgtConstants.IDENTITY_MANAGEMENT_CHALLENGES +
RegistryConstants.PATH_SEPARATOR + userDTO.getUserId() +
RegistryConstants.PATH_SEPARATOR + userDTO.getUserId();
Resource resource;
if (registry.resourceExists(identityKeyMgtPath)) {
resource = registry.get(identityKeyMgtPath);
String property = resource.getProperty(IdentityMgtConstants.VERIFIED_CHALLENGES);
if (property != null) {
return Integer.parseInt(property);
}
}
} catch (RegistryException e) {
log.error("Error while processing userKey", e);
}
return noOfChallenges;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:Utils.java
示例17: getConfigRegistryResourceContent
import org.wso2.carbon.registry.core.Resource; //导入依赖的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
示例18: addJWTConfigResourceToRegistry
import org.wso2.carbon.registry.core.Resource; //导入依赖的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
示例19: addSyslogConfig
import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
public void addSyslogConfig(SyslogData syslogData) throws Exception {
try {
registry.beginTransaction();
Resource syslogResource = registry.newResource();
syslogResource.addProperty(
LoggingConstants.SyslogProperties.LOG_INDEX_URL,
syslogData.getUrl());
syslogResource.addProperty(
LoggingConstants.SyslogProperties.SYSLOG_PORT,
syslogData.getPort());
syslogResource.addProperty(LoggingConstants.SyslogProperties.REALM,
syslogData.getRealm());
syslogResource.addProperty(
LoggingConstants.SyslogProperties.USER_NAME,
syslogData.getUserName());
syslogResource.addProperty(
LoggingConstants.SyslogProperties.PASSWORD,
encriptSyslogPassword(syslogData.getPassword()));
registry.put(LoggingConstants.SYSLOG, syslogResource);
registry.commitTransaction();
} catch (RegistryException e) {
registry.rollbackTransaction();
log.error("Cannot add syslog properties ", e);
throw e;
}
}
开发者ID:wso2,项目名称:carbon-commons,代码行数:27,代码来源:RegistryManager.java
示例20: testImportResource
import org.wso2.carbon.registry.core.Resource; //导入依赖的package包/类
public void testImportResource() throws Exception {
String[][] properties = new String[][]{{"key1", "val1"}, {"key2", "val2"}};
String path = ImportResourceUtil.importResource("/test/2017/10", "25", "application/xml", "Sample description",
"http://blog.napagoda.com/", "test", (UserRegistry) registry,
properties);
assertEquals("/test/2017/10/25", path);
Resource resource = registry.get("/test/2017/10/25");
assertEquals("application/xml", resource.getMediaType());
assertEquals("Sample description", resource.getDescription());
assertEquals("val1", resource.getPropertyValues("key1").get(0));
assertEquals("val2", resource.getProperty("key2"));
resource.discard();
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:ImportResourceUtilTest.java
注:本文中的org.wso2.carbon.registry.core.Resource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论