Package org.wso2.carbon.registry.core

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


            String dashboardConfigFile = dashboardDiskRoot + File.separator + "dashboard.xml";
            String gadgetsDiskLocation = dashboardDiskRoot + File.separator + "gadgets";

            // Check whether the system dasboard is already available if not populate
            Registry registry = DashboardPopulatorContext.getRegistry();
            if (!registry.resourceExists(REGISTRY_SYSTEM_DASHBOARDS_ROOT)) {

                // Creating an OMElement from file
                File dashboardConfigXml = new File(dashboardConfigFile);

                if (dashboardConfigXml.exists()) {
                    StAXOMBuilder sab = new StAXOMBuilder(new FileInputStream(dashboardConfigFile));
                    OMElement dashboardsRootEl = sab.getDocument().getOMDocumentElement();

                    FileReader dashboardConfigXmlReader = new FileReader(dashboardConfigXml);

                    // Restoring from file
                    registry.restore(REGISTRY_SYSTEM_DASHBOARDS_ROOT, dashboardConfigXmlReader);

                    log.info("Successfully populated the default Dashboards.");

                } else {
                    log.info("Couldn't find a Dashboard at '" + dashboardConfigFile +
                            "'. Giving up.");
                }
            }

            // Check whether Gadgets are stored. If not store
            if (!registry.resourceExists(GadgetPopulator.SYSTEM_GADGETS_PATH)) {

                File gadgetsDir = new File(gadgetsDiskLocation);
                if (gadgetsDir.exists()) {
                    GadgetPopulator.beginFileTansfer(gadgetsDir);
View Full Code Here


                    + service.getAxisServiceGroup().getServiceGroupName()
                    + RegistryResources.SERVICES + serviceName;
            UserRealm userRealm = AnonymousSessionUtil.getRealmByTenantDomain(
                    SecurityServiceHolder.getRegistryService(), SecurityServiceHolder.getRealmService(), tenantDomain);

            Registry rootRegistry = SecurityServiceHolder.getRegistryService().getRegistry();
            UserRegistry configRegistry = SecurityServiceHolder.getRegistryService().getConfigSystemRegistry(tenantID);

            ServicePasswordCallbackHandler handler = new ServicePasswordCallbackHandler(
                    serviceName, servicePath, configRegistry, userRealm);

            Parameter param = new Parameter();
            param.setName(WSHandlerConstants.PW_CALLBACK_REF);
            param.setValue(handler);
            service.addParameter(param);

            if (!secScenario.getScenarioId().equals(SecurityConstants.USERNAME_TOKEN_SCENARIO_ID)) {
                Parameter param2 = new Parameter();
                param2.setName("disableREST"); // TODO Find the constant
                param2.setValue(Boolean.TRUE.toString());
                service.addParameter(param2);
            }

            Resource serviceResource = configRegistry.get(servicePath);
            if (serviceResource.getProperty(SecurityConstants.PROP_RAHAS_SCT_ISSUER) != null) {

                Association[] pvtStores = rootRegistry.getAssociations(RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                                                                       servicePath,
                                                                       SecurityConstants.ASSOCIATION_PRIVATE_KEYSTORE);

                Properties cryptoProps = new Properties();
View Full Code Here

        }

        try {
            int tenantID = SuperTenantCarbonContext.getCurrentContext(msgCtx).getTenantId();
           
            Registry registry = SecurityServiceHolder.getRegistryService().getConfigSystemRegistry(tenantID);
            String servicePath = RegistryResources.SERVICE_GROUPS
                    + service.getAxisServiceGroup().getServiceGroupName()
                    + RegistryResources.SERVICES + service.getName();
            Resource serviceResource = null;
            if (registry.resourceExists(servicePath)) {
                serviceResource = registry.get(servicePath);
            } else {
                return InvocationResponse.CONTINUE;
            }

            if (serviceResource != null) {
View Full Code Here

        axisConfig.addObservers(secDeployInterceptor);

        //Store the policy resources in newly created tenant's config. registry
        HashMap<String, Resource> policyResourceMap = SecurityServiceHolder.getPolicyResourceMap();
        try {
            Registry registry = SecurityServiceHolder.getRegistryService().getConfigSystemRegistry(
                    tenantId);
            boolean transactionStarted = Transaction.isStarted();
            if (!transactionStarted) {
                registry.beginTransaction();
            }
            for (String resourceLoc : policyResourceMap.keySet()) {
                if (!registry.resourceExists(resourceLoc)) {
                    registry.put(resourceLoc, policyResourceMap.get(resourceLoc));
                }
            }
            if (!transactionStarted) {
                registry.commitTransaction();
            }
        } catch (Exception e) {
            String errorMsg = "Error when storing the policy resource in registry for tenant : " +
                              tenantId;
            log.error(errorMsg, e);
View Full Code Here

     * @throws SecurityConfigException - Error while loading policy
     */
    public Policy loadPolicy(String scenarioId, String policyPath) throws SecurityConfigException {

        try {
            Registry registryToLoad = registry;
            String resourceUri = SecurityConstants.SECURITY_POLICY + "/" + scenarioId;
            if (policyPath != null &&
                    scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
                resourceUri = policyPath.substring(policyPath.lastIndexOf(':') + 1);
                String regIdentifier = policyPath.substring(0, policyPath.lastIndexOf(':'));
                if (SecurityConstants.GOVERNANCE_REGISTRY_IDENTIFIER.equals(regIdentifier)) {
                    registryToLoad = govRegistry;
                }
            }
            Resource resource = registryToLoad.get(resourceUri);
            InputStream in = resource.getContentStream();

            XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in);
            StAXOMBuilder builder = new StAXOMBuilder(parser);

View Full Code Here

    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 = contextRoot.equals("/") ? "" : contextRoot;
View Full Code Here

     */
    private static final Log log = LogFactory.getLog(GadgetZipUploadHandler.class);

    public void put(RequestContext requestContext) throws RegistryException {

        Registry sysRegistry = GadgetRepoContext.getRegistryService().getConfigSystemRegistry();

        // adding the stream from the resource to the zip input

        String gadgetName = requestContext.getResource().getProperty(DashboardConstants.GADGET_NAME);

        ZipInputStream zis = new ZipInputStream(requestContext.getResource().getContentStream());
        ZipEntry zipentry = null;
        int i;
        byte[] buff = new byte[1024];
        try {
            zipentry = zis.getNextEntry();
            if (zipentry == null) {
                throw new RegistryException("Gadget bundle should be a zip file");
            }
        } catch (IOException e) {
            log.error(e);
        }

        sysRegistry.beginTransaction();
        while (zipentry != null) {
            String entryName = zipentry.getName();

            ByteArrayOutputStream byteOut = new ByteArrayOutputStream();

            if (zipentry.isDirectory()) {
                //if the entry is a directory creating a collection
                Collection col = sysRegistry.newCollection();
                sysRegistry.put(DashboardConstants.GS_REGISTRY_ROOT +
                                DashboardConstants.GADGET_PATH + gadgetName
                                + RegistryConstants.PATH_SEPARATOR + entryName, col);
            } else {
                //if a file, creating a resource
                Resource res = sysRegistry.newResource();
                try {
                    while ((i = zis.read(buff, 0, buff.length)) > 0) {
                        byteOut.write(buff, 0, i);
                    }
                } catch (IOException ioe) {
                    sysRegistry.rollbackTransaction();
                    log.error(ioe);
                }

                res.setContent(byteOut.toByteArray());

                // If entry is gadget xml then set its media type.
                if (entryName.contains(".xml")) {
                    res.setMediaType("application/vnd.wso2-gadget+xml");
                }

                sysRegistry.put(DashboardConstants.GS_REGISTRY_ROOT +
                                DashboardConstants.GADGET_PATH + gadgetName +
                                RegistryConstants.PATH_SEPARATOR + entryName, res);

            }
            try {
                zipentry = zis.getNextEntry();
            } catch (IOException e) {
                sysRegistry.rollbackTransaction();
                log.error(e);
            }
        }

        try {
            zis.close();
        } catch (IOException e) {
            log.error(e);
        }

        sysRegistry.commitTransaction();
        requestContext.setProcessingComplete(true);
    }
View Full Code Here

public class WSDLToolService extends AbstractAdmin {

    public void addMEXService(String path, ServiceInfoBean serviceInfo) throws Exception {
        Registry registry = getGovernanceRegistry();
        Resource resource = registry.newResource();
        //String parentPath = RegistryUtils.getParentPath(path);
        //String wsdlURL = serviceInfo.getWsdlURL();

        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMElement serviceInfoElement = fac.createOMElement("wsdltool", null);

        if (serviceInfo.getOwnerName() != null) {
            OMElement childElement = fac.createOMElement("wsdlurl", null);
            childElement.setText(serviceInfo.getWsdlURL());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getOwnerName() != null) {
            OMElement childElement = fac.createOMElement("ownername", null);
            childElement.setText(serviceInfo.getOwnerName());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getOwnerAddress() != null) {
            OMElement childElement = fac.createOMElement("owneraddress", null);
            childElement.setText(serviceInfo.getOwnerAddress());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getOwnerTelephone() != null) {
            OMElement childElement = fac.createOMElement("ownertelephone", null);
            childElement.setText(serviceInfo.getOwnerTelephone());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getOwnerEmail() != null) {
            OMElement childElement = fac.createOMElement("owneremail", null);
            childElement.setText(serviceInfo.getOwnerEmail());
            serviceInfoElement.addChild(childElement);
        }

        if (serviceInfo.getDescription() != null) {
            OMElement childElement = fac.createOMElement("description", null);
            childElement.setText(serviceInfo.getDescription());
            serviceInfoElement.addChild(childElement);
        }

        String content = serviceInfoElement.toString();
        resource.setContent(content.getBytes());
        resource.setMediaType(RegistryConstants.MEX_MEDIA_TYPE);
        registry.put(path, resource);
    }
View Full Code Here

            }
        }

        UserRealm realm = null;
        realm = IdentityTenantUtil.getRealm(null, null);
        Registry registry = IdentityTenantUtil.getRegistry(null, null);
        addUser(user.getUserName(), user.getPassword(), userClaims, null, realm);

        // OpenId Sign-Up if necessary.
        if (user.getOpenID() != null) {
            IdentityPersistenceManager persistentManager = IdentityPersistenceManager
View Full Code Here

                user = IdentityUtil.getPPIDDisplayValue(ppid);
                IdentityPersistenceManager manager = IdentityPersistenceManager
                        .getPersistanceManager();
                UserRealm realm = null;
                realm = IdentityTenantUtil.getRealm(null, null);
                Registry registry = null;
                registry = IdentityTenantUtil.getRegistry(null, null);
                addUser(user, uuid, userClaims, null, realm);
                PPIDValueDO ppidValueDO = new PPIDValueDO();
                ppidValueDO.setUserId(user);
                ppidValueDO.setPpid(ppid);
View Full Code Here

TOP

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

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.