本文整理汇总了Java中org.wso2.carbon.registry.core.session.UserRegistry.get方法的典型用法代码示例。如果您正苦于以下问题:Java UserRegistry.get方法的具体用法?Java UserRegistry.get怎么用?Java UserRegistry.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wso2.carbon.registry.core.session.UserRegistry
的用法示例。
在下文中一共展示了UserRegistry.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVerifiedChallenges
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的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;
}
示例2: getSubscription
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Subscription getSubscription(String id) throws EventBrokerException {
try {
UserRegistry userRegistry =
this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance()
.getTenantId());
Resource topicIndexResource = userRegistry.get(this.indexStoragePath);
String subscriptionPath = getResourcePath(id, topicIndexResource.getProperty(id));
if (subscriptionPath != null && userRegistry.resourceExists(subscriptionPath)) {
Resource subscriptionResource = userRegistry.get(subscriptionPath);
Subscription subscription = JavaUtil.getSubscription(subscriptionResource);
subscription.setTenantId(EventBrokerHolder.getInstance().getTenantId());
return subscription;
} else {
return null;
}
} catch (RegistryException e) {
throw new EventBrokerException("Cannot access the registry ", e);
}
}
示例3: validateDomainFromSuccessKey
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* validates domain from the successkey
*
* @param governanceSystemRegistry - The governance system registry
* @param domain - tenant domain
* @param successKey - successkey
* @return true, if successfully validated
* @throws RegistryException, if validation failed
*/
public static boolean validateDomainFromSuccessKey(UserRegistry governanceSystemRegistry,
String domain, String successKey)
throws RegistryException {
String domainValidatorInfoPath =
StratosConstants.DOMAIN_VALIDATOR_INFO_PATH + RegistryConstants.PATH_SEPARATOR +
domain + RegistryConstants.PATH_SEPARATOR +
StratosConstants.VALIDATION_KEY_RESOURCE_NAME;
if (governanceSystemRegistry.resourceExists(domainValidatorInfoPath)) {
Resource resource = governanceSystemRegistry.get(domainValidatorInfoPath);
String actualSuccessKey = resource.getProperty("successKey");
if (actualSuccessKey != null && successKey != null &&
actualSuccessKey.trim().equals(successKey.trim())) {
// the domain is correct
return true;
}
}
return false;
}
示例4: validateDomainFromSuccessKey
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* validates domain from the successkey
*
* @param governanceSystemRegistry - The governance system registry
* @param domain - tenant domain
* @param successKey - successkey
* @return true, if successfully validated
* @throws RegistryException, if validation failed
*/
public static boolean validateDomainFromSuccessKey(UserRegistry governanceSystemRegistry,
String domain, String successKey)
throws RegistryException {
String domainValidatorInfoPath =
StratosConstants.DOMAIN_VALIDATOR_INFO_PATH + RegistryConstants.PATH_SEPARATOR +
domain + RegistryConstants.PATH_SEPARATOR +
StratosConstants.VALIDATION_KEY_RESOURCE_NAME;
if (governanceSystemRegistry.resourceExists(domainValidatorInfoPath)) {
Resource resource = governanceSystemRegistry.get(domainValidatorInfoPath);
String actualSuccessKey = resource.getProperty("successKey");
if (actualSuccessKey != null && successKey != null &&
actualSuccessKey.trim().equals(successKey.trim())) {
// the domain is correct
return true;
}
}
return false;
}
示例5: isCloudServiceActive
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public static boolean isCloudServiceActive(String cloudServiceName,
int tenantId, UserRegistry govRegistry)
throws Exception {
// The cloud manager is always active
if (StratosConstants.CLOUD_MANAGER_SERVICE.equals(cloudServiceName)) {
return true;
}
String cloudServiceInfoPath = StratosConstants.CLOUD_SERVICE_INFO_STORE_PATH +
RegistryConstants.PATH_SEPARATOR + tenantId +
RegistryConstants.PATH_SEPARATOR + cloudServiceName;
Resource cloudServiceInfoResource;
if (govRegistry.resourceExists(cloudServiceInfoPath)) {
cloudServiceInfoResource = govRegistry.get(cloudServiceInfoPath);
String isActiveStr =
cloudServiceInfoResource.getProperty(
StratosConstants.CLOUD_SERVICE_IS_ACTIVE_PROP_KEY);
return "true".equals(isActiveStr);
}
return false;
}
示例6: provideChildAssociations
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
private static List provideChildAssociations(
String path, String assoType, UserRegistry registry)
throws RegistryException {
List tmpAssociations = new ArrayList();
List associations = new ArrayList();
ResourcePath resourcePath = new ResourcePath(path);
Resource resource = registry.get(path);
Association[] asso = CommonUtil.getAssociations(registry, (resourcePath.isCurrentVersion() ?
resourcePath.getPath() : resourcePath.getPathWithVersion()));
tmpAssociations.addAll(Arrays.asList(asso));
Iterator iAssociations = tmpAssociations.iterator();
while (iAssociations.hasNext()) {
Association tmpAsso = (Association) iAssociations.next();
//Get all associations filtered by it's association type
if (tmpAsso.getAssociationType().equals(CommonConstants.ASSOCIATION_TYPE01)
&& assoType.equals(CommonConstants.ASSOCIATION_TYPE01) && tmpAsso.getSourcePath().equals(path))
associations.add(tmpAsso);
if (!tmpAsso.getAssociationType().equals(CommonConstants.ASSOCIATION_TYPE01)
&& !assoType.equals(CommonConstants.ASSOCIATION_TYPE01) && tmpAsso.getSourcePath().equals(path))
associations.add(tmpAsso);
}
resource.discard();
// if path is equal to the destination path, it is a backward association. we are only displaying
// the forward associations here
return associations;
}
示例7: getLifeCycleStateBean
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
@Override
public LCStateBean getLifeCycleStateBean(String artifactId, String artifactLC)
throws LifeCycleException {
try {
UserRegistry registry = (UserRegistry) getGovernanceUserRegistry();
UserRealm userRealm = registry.getUserRealm();
String[] roleNames = userRealm.getUserStoreManager().getRoleListOfUser(registry.getUserName());
String path = GovernanceUtils.getArtifactPath(registry, artifactId);
if (path != null) {
removeCache(registry, path);
Resource resource = registry.get(path);
LCStateBean lifeCycleStateBean = getCheckListItems(resource, artifactLC, roleNames, registry);
GovernanceArtifact governanceArtifact =
GovernanceUtils.retrieveGovernanceArtifactById(registry, artifactId);
Map<String, String> currentStateDurationData = governanceArtifact
.getCurrentStateDuration(artifactId, artifactLC);
if (currentStateDurationData != null && !currentStateDurationData.isEmpty()) {
lifeCycleStateBean
.setLifeCycleCurrentStateDuration(currentStateDurationData.get("currentStateDuration"));
lifeCycleStateBean
.setLifeCycleCurrentStateDurationColour(currentStateDurationData.get("durationColour"));
}
return lifeCycleStateBean;
} else {
throw new LifeCycleException("Unable to find the artifact " + artifactId);
}
} catch (UserStoreException | RegistryException e) {
throw new LifeCycleException(e);
}
}
示例8: deleteQueue
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* Delete the entry for a queue from the Registry
*
* @param queueName Name of the queue to be deleted
* @throws RegistryClientException
*/
public static void deleteQueue(String queueName)
throws RegistryClientException {
try {
RegistryService registryService = CommonsDataHolder.getInstance().getRegistryService();
if (registryService != null) {
UserRegistry registry = registryService.getGovernanceSystemRegistry();
// Delete queue
String queueID = CommonsUtil.getQueueID(queueName);
if (registry.resourceExists(queueID)) {
String createdFrom = registry.get(queueID).getProperty(CREATED_FROM);
if ((null != createdFrom) && (CREATED_FROM_AMQP.equals(createdFrom))) {
Collection queue = (Collection) registry.get(queueID);
String userCount = queue.getProperty(USER_COUNT);
if (null != userCount) {
int count = Integer.parseInt(userCount);
if (count > 1) {
queue.setProperty(USER_COUNT, Integer.toString(--count));
registry.put(queueID, queue);
} else {
registry.delete(queueID);
}
}
}
}
}
} catch (RegistryException e) {
throw new RegistryClientException(e);
}
}
示例9: unSubscribe
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void unSubscribe(String subscriptionID) throws EventBrokerException {
try {
UserRegistry userRegistry =
this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance()
.getTenantId());
String fullPath = this.indexStoragePath;
if (userRegistry.resourceExists(fullPath)) {
Resource topicIndexResource = userRegistry.get(fullPath);
String topicName = topicIndexResource.getProperty(subscriptionID);
// delete the subscriptions resource
// if the registry is read only there can be situations where the the subscriptions
// is not saved to registry and hence the topic name
if (topicName != null) {
String resourcePath = getResourcePath(subscriptionID, topicName);
if (userRegistry.resourceExists(resourcePath)) {
userRegistry.delete(resourcePath);
}
String jMSResourcePath = getJMSSubResourcePath(subscriptionID, topicName);
if (userRegistry.resourceExists(jMSResourcePath)) {
userRegistry.delete(jMSResourcePath);
}
}
topicIndexResource.removeProperty(subscriptionID);
userRegistry.put(fullPath, topicIndexResource);
}
} catch (RegistryException e) {
throw new EventBrokerException("Cannot access the registry ", e);
}
}
示例10: getJMSSubscriptions
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Subscription[] getJMSSubscriptions(String topicName) throws EventBrokerException {
try {
Subscription[] subscriptionsArray = new Subscription[0];
UserRegistry userRegistry =
this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId());
String resourcePath = JavaUtil.getResourcePath(topicName, this.topicStoragePath);
if (!resourcePath.endsWith("/")) {
resourcePath = resourcePath + "/";
}
resourcePath = resourcePath + EventBrokerConstants.EB_CONF_JMS_SUBSCRIPTION_COLLECTION_NAME;
// Get subscriptions
if (userRegistry.resourceExists(resourcePath)) {
Collection subscriptionCollection = (Collection) userRegistry.get(resourcePath);
subscriptionsArray =
new Subscription[subscriptionCollection.getChildCount()];
int index = 0;
for (String subs : subscriptionCollection.getChildren()) {
Collection subscription = (Collection) userRegistry.get(subs);
Subscription subscriptionDetails = new Subscription();
subscriptionDetails.setId(subscription.getProperty("Name"));
subscriptionDetails.setOwner(subscription.getProperty("Owner"));
subscriptionDetails.setCreatedTime(ConverterUtil.convertToDate(subscription.getProperty("createdTime")));
subscriptionsArray[index++] = subscriptionDetails;
}
}
return subscriptionsArray;
} catch (RegistryException e) {
throw new EventBrokerException("Cannot read the registry resources ", e);
}
}
示例11: doEncrypt
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public void doEncrypt(String plainTextValue, String alias) {
try {
createRegistryResource();
UserRegistry registry = SecurityServiceHolder.getInstance().getRegistryService().getConfigSystemRegistry();
Resource registryResource = registry.get(SecureVaultConstants.ENCRYPTED_PROPERTY_STORAGE_PATH);
String encryptedValue = SecureVaultUtil.encryptValue(plainTextValue);
registryResource.addProperty(alias, encryptedValue);
registry.put(SecureVaultConstants.ENCRYPTED_PROPERTY_STORAGE_PATH, registryResource);
} catch (RegistryException | AxisFault e) {
}
}
示例12: updateMediaType
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public static void updateMediaType(UserRegistry userRegistry, String path, String mediaType)
throws RegistryException {
try {
Resource currentResource = userRegistry.get(path);
currentResource.setMediaType(mediaType);
userRegistry.put(path, currentResource);
} catch (RegistryException e) {
throw new RegistryException("Failed to update media type of the resource : "+path);
}
}
示例13: invokeProtocolHandler
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
private synchronized void invokeProtocolHandler(ExitProtocolMessage message) {
OMElement payload = message.toOM();
Options options = new Options();
options.setTo(new EndpointReference(message.getTaskProtocolHandlerURL()));
options.setAction(WSConstants.WS_HT_COORDINATION_PROTOCOL_EXIT_ACTION);
options.setTransportInProtocol(org.apache.axis2.Constants.TRANSPORT_HTTPS);
ServiceClient serviceClient = null;
try {
serviceClient = new ServiceClient();
serviceClient.setOptions(options);
//Setting basic auth headers.
String tenantDomain = MultitenantUtils.getTenantDomainFromUrl(message.getTaskProtocolHandlerURL());
if (message.getTaskProtocolHandlerURL().equals(tenantDomain)) {
//this is a Super tenant registration service
CarbonUtils.setBasicAccessSecurityHeaders(CoordinationConfiguration.getInstance()
.getProtocolHandlerAdminUser()
, CoordinationConfiguration.getInstance().getProtocolHandlerAdminPassword(), serviceClient);
} else {
if (log.isDebugEnabled()) {
log.debug("Sending exit protocol message to tenant domain: " + tenantDomain);
}
// Tenant's registration service
String username = "";
String password = "";
try {
UserRegistry configSystemRegistry = B4PContentHolder.getInstance().getRegistryService()
.getConfigSystemRegistry(tenantID);
Resource taskCoordination = configSystemRegistry.get(REG_TASK_COORDINATION);
if (taskCoordination != null) {
username = taskCoordination.getProperty(USERNAME);
password = taskCoordination.getProperty(PASSWORD);
} else {
log.error("Task coordination is not configured for tenant : " + tenantDomain +
". Dropping Exit Coordination message. Affected Tasks ids : " + message.getTaskIDs());
return;
}
} catch (RegistryException e) {
log.warn("Error while accessing Registry Service for tenant : " + tenantDomain +
". Dropping Exit Coordination message. Affected Tasks ids : " + message.getTaskIDs(), e);
return;
}
CarbonUtils.setBasicAccessSecurityHeaders(username, password, serviceClient);
}
serviceClient.fireAndForget(payload);
if (log.isDebugEnabled()) {
log.debug("Sent exit protocol message to " + message.getTaskProtocolHandlerURL());
}
} catch (AxisFault axisFault) {
log.error("Error occurred while invoking HT Protocol Handler " + message.getTaskProtocolHandlerURL() +
". Affected Tasks ids : " + message.getTaskIDs(), axisFault);
}
}
示例14: populate
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
public static DependenciesBean populate(UserRegistry userRegistry, String path) {
DependenciesBean dependenciesBean = new DependenciesBean();
ResourcePath resourcePath = new ResourcePath(path);
try {
Association[] asso = CommonUtil.getAssociations(userRegistry,
(resourcePath.isCurrentVersion() ?
resourcePath.getPath() : resourcePath.getPathWithVersion()));
Resource resource = userRegistry.get(path);
AssociationBean[] beans = new AssociationBean[asso.length];
for (int i = 0; i < beans.length; i++) {
Association as = asso[i];
beans[i] = new AssociationBean(as.getSourcePath(), as.getDestinationPath(),
as.getAssociationType());
}
dependenciesBean.setAssociationBeans(beans);
dependenciesBean.setVersionView(!resourcePath.isCurrentVersion());
dependenciesBean.setPathWithVersion(resourcePath.getPathWithVersion());
List mountPoints = resource.getPropertyValues("registry.mountpoint");
List targetPoints = resource.getPropertyValues("registry.targetpoint");
// List paths = resource.getPropertyValues("registry.path");
List actualPaths = resource.getPropertyValues("registry.actualpath");
String user = resource.getProperty("registry.user");
if (resource.getProperty("registry.link") != null) {
if(mountPoints != null && targetPoints != null) {
// String mountPoint = (String)mountPoints.get(0);
// String targetPoint = (String)targetPoints.get(0);
// String tempPath;
// if (targetPoint.equals(RegistryConstants.PATH_SEPARATOR) && !path.equals(mountPoint)) {
// tempPath = ((String)paths.get(0)).substring(mountPoint.length());
// } else {
// tempPath = targetPoint + ((String)paths.get(0)).substring(mountPoint.length());
// }
String tempPath = (String)actualPaths.get(0);
dependenciesBean.setPutAllowed(
UserUtil.isPutAllowed(userRegistry.getUserName(), tempPath, userRegistry));
} else if (user != null) {
if (userRegistry.getUserName().equals(user)) {
dependenciesBean.setPutAllowed(true);
} else {
dependenciesBean.setPutAllowed(UserUtil.isPutAllowed(
userRegistry.getUserName(), path, userRegistry));
}
}
} else {
dependenciesBean.setPutAllowed(UserUtil.isPutAllowed(userRegistry.getUserName(), path, userRegistry));
}
dependenciesBean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(userRegistry.getUserName()));
} catch (RegistryException e) {
String msg = "Failed to get dependencies of resource " +
resourcePath + ". " + e.getMessage();
dependenciesBean.setErrorMessage(msg);
}
return dependenciesBean;
}
示例15: searchByTags
import org.wso2.carbon.registry.core.session.UserRegistry; //导入方法依赖的package包/类
private static ResourceData [] searchByTags(String tag, UserRegistry registry)
throws RegistryException {
ResourceData[] resourceDataList = new ResourceData[0];
if (tag != null && tag.length() != 0) {
TaggedResourcePath[] taggedPaths = registry.getResourcePathsWithTag(tag);
resourceDataList = new ResourceData [taggedPaths.length];
for (int i=0; i<taggedPaths.length; i++) {
String resultPath = taggedPaths[i].getResourcePath();
ResourceData resourceData = new ResourceData();
resourceData.setResourcePath(resultPath);
if (resultPath != null) {
if (resultPath.equals(RegistryConstants.ROOT_PATH)) {
resourceData.setName(RegistryConstants.ROOT_PATH);
} else {
String[] parts = resultPath.split(RegistryConstants.PATH_SEPARATOR);
resourceData.setName(parts[parts.length - 1]);
}
}
try {
Resource child = registry.get(resultPath);
resourceData.setResourceType(child instanceof Collection ?
"collection" : "resource");
resourceData.setAuthorUserName(child.getAuthorUserName());
resourceData.setDescription(child.getDescription());
resourceData.setAverageRating(registry.getAverageRating(child.getPath()));
Calendar createdDateTime = Calendar.getInstance();
createdDateTime.setTime(child.getCreatedTime());
resourceData.setCreatedOn(createdDateTime);
Map counts = taggedPaths[i].getTagCounts();
Object [] keySet = counts.keySet().toArray();
TagCount [] tagCounts = new TagCount [counts.size()];
for(int j=0; j<counts.size(); j++) {
TagCount tagCount = new TagCount();
tagCount.setKey((String)keySet[j]);
tagCount.setValue((Long)counts.get(keySet[j]));
tagCounts[j] = tagCount;
}
resourceData.setTagCounts(tagCounts);
CommonUtil.populateAverageStars(resourceData);
child.discard();
resourceDataList[i] = resourceData;
} catch (AuthorizationFailedException e) {
// do not show unauthorized resources in search results
}
}
}
return resourceDataList;
}