本文整理汇总了Java中org.wso2.carbon.registry.core.Registry类的典型用法代码示例。如果您正苦于以下问题:Java Registry类的具体用法?Java Registry怎么用?Java Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Registry类属于org.wso2.carbon.registry.core包,在下文中一共展示了Registry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}