Package org.wso2.carbon.registry.core

Examples of org.wso2.carbon.registry.core.Resource


     * @return the endpoint artifact that corresponds.
     * @throws GovernanceException if the operation failed.
     */
    public Endpoint getEndpointByUrl(String url) throws GovernanceException {
        String path = CommonUtil.getEndpointPathFromUrl(url);
        Resource r;
        try {
            if (registry.resourceExists(path)) {
                r = registry.get(path);
            } else {
                return null;
            }
        } catch (RegistryException e) {
            String msg =
                    "Error in retrieving the endpoint resource. url:" + url + ", path:" + path +
                            ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        }
        String artifactId = r.getProperty(GovernanceConstants.ARTIFACT_ID_PROP_KEY);
        if (artifactId != null) {
            return getEndpoint(artifactId);
        }
        return null;
    }
View Full Code Here


        Boolean response = false;

        try {
            Registry registry = DashboardContext.getRegistry(MultitenantUtils.getTenantId(DashboardContext.getConfigContext()));

            Resource regAdminDataResource;
            if (registry.resourceExists(
                    DashboardConstants.REGISTRY_ADMIN_PROPERTIES_PATH)) {
                regAdminDataResource = registry.get(
                        DashboardConstants.REGISTRY_ADMIN_PROPERTIES_PATH);

                String storedValue = regAdminDataResource
                        .getProperty(
                                DashboardConstants.ANON_MODE_ACT);

                if ((storedValue != null) && ("true".equals(storedValue))) {
                    return true;
View Full Code Here

     */
    private String[] getGadgetUrlSetForUnSignedUser() {
        Registry registry;
        try {
            registry = getConfigSystemRegistry();
            Resource comQuery = registry.newResource();

            String sql = "SELECT R.REG_NAME, R.REG_PATH_ID FROM REG_RESOURCE R, REG_PROPERTY P, REG_RESOURCE_PROPERTY RP, REG_PATH PA WHERE "
                    + "R.REG_VERSION=RP.REG_VERSION AND "
                    + "P.REG_NAME='"
                    + DashboardConstants.UNSIGNED_USER_GADGET
                    + "' AND "
                    + "P.REG_VALUE='true' AND "
                    + "P.REG_ID=RP.REG_PROPERTY_ID AND "
                    + "PA.REG_PATH_ID=R.REG_PATH_ID";

            HashMap<String, String> map = new HashMap<String, String>();
            map.put("query", sql);
            Collection qResults = registry.executeQuery(null, map);

            String[] qPaths = (String[]) qResults.getContent();
            ArrayList gadgetUrlsList = new ArrayList();

            for (String qPath : qPaths) {
                if (registry.resourceExists(qPath)) {
                    Resource tempRes = registry.get(qPath);
                    String gadgetNameTmp = tempRes.getProperty(DashboardConstants.GADGET_NAME);
                    String gadgetUrlTmp = tempRes.getProperty(DashboardConstants.GADGET_URL);
                    if (isGadgetAutharized(CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME, gadgetUrlTmp)) {
                        gadgetUrlsList.add(gadgetNameTmp + "," + gadgetUrlTmp);
                    }
                }
            }
View Full Code Here

        String[] servicePaths = result.getChildren();

        Map<String, LifecycleInfoBean> lifecycleInfoBeanMap = new HashMap<String, LifecycleInfoBean>();
        Map<String, List<LifecycleStageInfoBean>> lifecycleStagesMap = new HashMap<String, List<LifecycleStageInfoBean>>();
        for (String servicePath: servicePaths) {
            Resource serviceResource = registry.get(servicePath);
            String lifecycleName = serviceResource.getProperty("registry.Aspects");
            if (lifecycleName != null) {
                lifecycleName = lifecycleName.replaceAll("\\s", "");
                LifecycleInfoBean lifecycleInfoBean = lifecycleInfoBeanMap.get(lifecycleName);
                List<LifecycleStageInfoBean> lifecycleStages = lifecycleStagesMap.get(lifecycleName);
                if (lifecycleInfoBean == null) {
                    lifecycleInfoBean = new LifecycleInfoBean();
                    lifecycleInfoBean.setName(lifecycleName);
                    lifecycleInfoBeanMap.put(lifecycleName, lifecycleInfoBean);

                    // initializing lifecycle stages
                    lifecycleStages = new ArrayList<LifecycleStageInfoBean>();
                    lifecycleStagesMap.put(lifecycleName, lifecycleStages);
                }
                String lifecycleStageKey = "registry.lifecycle." + lifecycleName + ".state";
                String lifecycleStageValue = serviceResource.getProperty(lifecycleStageKey);

                LifecycleStageInfoBean lifecycleStageInfoBean = null;
               
                // iterate and find the correct stage object
                for (int i = 0; i < lifecycleStages.size(); i ++) {
View Full Code Here

            String fileRegistryPath =
                    SYSTEM_GADGETS_PATH + file.getAbsolutePath().substring(rootPath.length())
                            .replaceAll("[/\\\\]+", "/");

            // Adding the file to the Registry            
            Resource fileResource = registry.newResource();
            fileResource.setMediaType(new MimetypesFileTypeMap().getContentType(file));
            fileResource.setContentStream(new FileInputStream(file));
            registry.put(fileRegistryPath, fileResource);

        } catch (DashboardPopulatorException e) {
            log.error(e);
        } catch (RegistryException e) {
View Full Code Here

    public void loadEndpointDetails() throws GovernanceException {
        checkRegistryResourceAssociation();
        Registry registry = getAssociatedRegistry();
        String path = getPath();
        String id = getId();
        Resource resource;
        try {
            resource = registry.get(path);
            Object contentObj = resource.getContent();
            if (contentObj instanceof String) {
                url = (String) contentObj;
            } else {
                byte[] content = (byte[]) contentObj;
                url = new String(content);
            }

        } catch (RegistryException e) {
            String msg =
                    "Error in getting the content for the artifact. artifact id: " + id + ", " +
                            "path: " + path + ".";
            log.error(msg, e);
            throw new GovernanceException(msg, e);
        }

        // and then iterate all the properties and add.
        Properties properties = resource.getProperties();
        if (properties != null) {
            Set keySet = properties.keySet();
            if (keySet != null) {
                for (Object keyObj : keySet) {
                    String key = (String) keyObj;
View Full Code Here

          if (RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE
              .equals(fullname)) {
            continue;
          }

          Resource store = registry.get(ks[i]);
          int lastIndex = fullname.lastIndexOf("/");
          String name = fullname.substring(lastIndex + 1);
          String type = store.getProperty(SecurityConstants.PROP_TYPE);
          String provider = store.getProperty(SecurityConstants.PROP_PROVIDER);

          KeyStoreData data = new KeyStoreData();
          data.setKeyStoreName(name);
          data.setKeyStoreType(type);
          data.setProvider(provider);

          String alias = store.getProperty(SecurityConstants.PROP_PRIVATE_KEY_ALIAS);
          if (alias != null) {
            data.setPrivateStore(true);
          } else {
            data.setPrivateStore(false);
          }

                    // Dump the generated public key to the file system for sub tenants
                    if(!isSuperTenant){
                        Association[] associations = registry.getAssociations(
                                ks[i],SecurityConstants.ASSOCIATION_TENANT_KS_PUB_KEY);
                        if(associations != null && associations.length > 0){
                            Resource pubKeyResource = registry.get(associations[0].getDestinationPath());
                            String fileName = generatePubCertFileName(ks[i],
                                                                      pubKeyResource.getProperty(
                                                                              SecurityConstants.PROP_TENANT_PUB_KEY_FILE_NAME_APPENDER));
                            String pubKeyFilePath = KeyStoreMgtUtil.dumpCert(
                                    MessageContext.getCurrentMessageContext().getConfigurationContext(),
                                    (byte[])pubKeyResource.getContent(), fileName);
                            data.setPubKeyFilePath(pubKeyFilePath);
                        }
                    }
          lst.add(data);
View Full Code Here

      // just to test weather pvt key password is correct.
      keyStore.getKey(pvtKeyAlias, pvtkeyPass.toCharArray());

      CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil();

      Resource resource = registry.newResource();
      resource.addProperty(SecurityConstants.PROP_PASSWORD, cryptoUtil
          .encryptAndBase64Encode(password.getBytes()));
      resource.addProperty(SecurityConstants.PROP_PROVIDER, provider);
      resource.addProperty(SecurityConstants.PROP_TYPE, type);

      if (pvtKeyAlias != null) {
        resource.addProperty(SecurityConstants.PROP_PRIVATE_KEY_ALIAS, pvtKeyAlias);
        resource.addProperty(SecurityConstants.PROP_PRIVATE_KEY_PASS, cryptoUtil
            .encryptAndBase64Encode(pvtkeyPass.getBytes()));
      }

      resource.setContent(content);
      registry.put(path, resource);
    } catch (SecurityConfigException e) {
      throw e;
    } catch (Exception e) {
      log.error(e.getMessage(), e);
View Full Code Here

      } else {
        String path = SecurityConstants.KEY_STORES + "/" + keyStoreName;
        if (!registry.resourceExists(path)) {
          throw new SecurityConfigException("Key Store not found");
        }
        Resource resource = registry.get(path);
        KeyStoreManager manager = KeyStoreManager.getInstance((UserRegistry)registry);
        keyStore = manager.getKeyStore(keyStoreName);
        keyStoreType = resource.getProperty(SecurityConstants.PROP_TYPE);

        String encpass = resource.getProperty(SecurityConstants.PROP_PRIVATE_KEY_PASS);

        CryptoUtil util = CryptoUtil.getDefaultCryptoUtil();
        privateKeyPassowrd = new String(util.base64DecodeAndDecrypt(encpass));

      }
View Full Code Here

    private void persistTrustedService(String groupName, String serviceName, String trustedService,
            String certAlias) 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) {
                if (registry.resourceExists(resourcePath)) {
                    resource = registry.get(resourcePath);
                } else {
                    resource = registry.newResource();
                }
                if (resource.getProperty(trustedService) != null) {
                    resource.removeProperty(trustedService);
                }
                resource.addProperty(trustedService, certAlias);
                registry.put(resourcePath, resource);
            }
        } catch (Exception e) {
            log.error("Error occured while adding trusted service for STS", e);
            throw new SecurityConfigException("Error occured while adding trusted service for STS",
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.