Examples of UserRegistry


Examples of org.wso2.carbon.registry.core.session.UserRegistry

                        registry.put(directoryRegistryPath, newCollection);
                    }

                    // Set permission for anonymous read. We do it here because it should happen always in order
                    // to support mounting a remote registry.
                    UserRegistry userRegistry = getRegistry(tenantId);
                    AuthorizationManager accessControlAdmin =
                            userRegistry.getUserRealm().getAuthorizationManager();

                    if (!accessControlAdmin.isRoleAuthorized(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                            REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET)) {
                        accessControlAdmin.authorizeRole(CarbonConstants.REGISTRY_ANONNYMOUS_ROLE_NAME, RegistryConstants.CONFIG_REGISTRY_BASE_PATH +
                                REGISTRY_GADGET_STORAGE_PATH, ActionConstants.GET);
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

     * Getting the service either from the Registry service or other means.
     *
     * @return UserRegistry - The registry instance.
     */
    private static UserRegistry getRegistry(int tenantId) {
        UserRegistry registry = null;
        try {
            // registry = (UserRegistry) DashboardContext.getRegistry(tenantId);
            // int tID = SuperTenantCarbonContext.getCurrentContext().getTenantId();
            registry = (UserRegistry) DashboardContext.getRegistry(tenantId);

View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

        try {
            int tenantId =
                           SuperTenantCarbonContext.getCurrentContext(axisConfiguration)
                                                   .getTenantId();
            Collection<SecurityScenario> scenarios = SecurityScenarioDatabase.getAllScenarios();
            UserRegistry tenantUserRegistry =
                                              IdentitySTSMgtServiceComponent.getRegistryService()
                                                                            .getConfigSystemRegistry(tenantId);
            for (Iterator<SecurityScenario> ite = scenarios.iterator(); ite.hasNext();) {
                SecurityScenario scenario = ite.next();
                String scenarioId = scenario.getScenarioId();
                if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
                        !scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
                    String resourceUri = SecurityConstants.SECURITY_POLICY + "/" + scenarioId;
                    if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) &&
                            !scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) {
                        Resource scenarioResource = tenantUserRegistry.newResource();
                        URL resource =
                                       IdentitySTSMgtServiceComponent.getBundleContext().
                                                                      getBundle().
                                                                      getResource(scenarioId +
                                                                                  "-policy.xml");
                        if (resource != null) {
                            scenarioResource.setContentStream(resource.openStream());
                            tenantUserRegistry.put(resourceUri, scenarioResource);
                        } else {
                            log.error("Could not load policy scenario " + scenarioId +
                                      " for tenant " + tenantId);
                        }
                    }
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

        }

        HttpServletRequest request =
                (HttpServletRequest) messageContext.getProperty("transport.http.servletRequest");

        UserRegistry registry =
                (UserRegistry) request.getSession().getAttribute(RegistryConstants.USER_REGISTRY);

        if (registry == null) {
            String msg = "User Registry instance is not found. " +
                    "Users have to login to retrieve a user registry instance for the tenant. ";
            log.error(msg);
            throw new UserProfileException(msg);
        }

        return registry.getUserRealm();
    }
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

public class ListMetadataService extends AbstractAdmin {

    private static final Log log = LogFactory.getLog(ListMetadataService.class);

    public ServiceBean listservices(String criteria)throws RegistryException{
        UserRegistry registry = (UserRegistry)getGovernanceRegistry();
        ServiceBean bean = new ServiceBean();
        Resource resource;
        String[] path;
        try {
            path = ListServiceUtil.filterServices(criteria, registry);
        } catch (RegistryException e) {
            log.error("An error occurred while obtaining the list of services.", e);
            path = new String[0];
        }
        String[] name = new String[path.length];
        String[] namespace = new String[path.length];
        boolean[] canDelete = new boolean[path.length];
        for(int i=0;i<path.length;i++){
            bean.increment();
            resource = registry.get(path[i]);

            if(path[i].startsWith(RegistryConstants.PATH_SEPARATOR+"trunk")){
                try {
                    OMElement omElement = AXIOMUtil.stringToOM(new String((byte[])resource.getContent()));
                    Iterator it = omElement.getChildrenWithLocalName("overview");
                    while (it.hasNext()) {
                        OMElement element = (OMElement) it.next();
                        Iterator iterator = element.getChildrenWithLocalName("version");
                        while (iterator.hasNext()) {
                            OMElement next = (OMElement) iterator.next();
                            path[i] = org.wso2.carbon.registry.extensions.utils.CommonUtil.computeServicePathWithVersion(path[i],next.getText());
                            break;
                        }
                    }
                } catch (XMLStreamException e) {
                    log.error("Error parsing the resource content",e);
                }
            }
            name[i] = CommonUtil.getServiceName(resource);
            namespace[i] = CommonUtil.getServiceNamespace(resource);
            if (registry.getUserRealm() != null && registry.getUserName() != null) {
                try {
                    canDelete[i] =
                            registry.getUserRealm().getAuthorizationManager().isUserAuthorized(
                                    registry.getUserName(),
                                    RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + path[i],
                                    ActionConstants.DELETE);
                } catch (UserStoreException e) {
                    canDelete[i] = false;
                }
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

        bean.setCanDelete(canDelete);
        return bean;
    }
    public WSDLBean listwsdls()throws RegistryException{
        WSDLBean bean = new WSDLBean();
        UserRegistry registry = (UserRegistry)getGovernanceRegistry();
        String[] path;
        try {
            path = QueryUtil.getResult(RegistryConstants.WSDL_MEDIA_TYPE,
                    getConfigSystemRegistry(),
                    getGovernanceRegistry());
        } catch (RegistryException e) {
            log.error("An error occurred while obtaining the list of WSDLs.", e);
            path = new String[0];
        }
        String[] name = new String[path.length];
        boolean[] canDelete = new boolean[path.length];
        for(int i=0;i<path.length;i++){
            bean.increment();
            name[i] = CommonUtil.getResourceName(path[i]);
            if (registry.getUserRealm() != null && registry.getUserName() != null) {
                try {
                    canDelete[i] =
                            registry.getUserRealm().getAuthorizationManager().isUserAuthorized(
                                    registry.getUserName(),
                                    RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + path[i],
                                    ActionConstants.DELETE);
                } catch (UserStoreException e) {
                    canDelete[i] = false;
                }
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

        bean.setCanDelete(canDelete);
        return bean;
    }
    public PolicyBean listpolicies()throws RegistryException{
        PolicyBean bean = new PolicyBean();
        UserRegistry registry = (UserRegistry)getGovernanceRegistry();
        String[] path;
        try {
            path = QueryUtil.getResult(RegistryConstants.POLICY_MEDIA_TYPE,
                    getConfigSystemRegistry(),
                    getGovernanceRegistry());
        } catch (RegistryException e) {
            log.error("An error occurred while obtaining the list of policies.", e);
            path = new String[0];
        }
        String[] name = new String[path.length];
        boolean[] canDelete = new boolean[path.length];
        for(int i=0;i<path.length;i++){
            bean.increment();
            name[i] = CommonUtil.getResourceName(path[i]);
            if (registry.getUserRealm() != null && registry.getUserName() != null) {
                try {
                    canDelete[i] =
                            registry.getUserRealm().getAuthorizationManager().isUserAuthorized(
                                    registry.getUserName(),
                                    RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + path[i],
                                    ActionConstants.DELETE);
                } catch (UserStoreException e) {
                    canDelete[i] = false;
                }
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

        bean.setCanDelete(canDelete);
        return bean;
    }
    public SchemaBean listschema()throws RegistryException{
        SchemaBean bean = new SchemaBean();
        UserRegistry registry = (UserRegistry)getGovernanceRegistry();
        String[] path;
        try {
            path = QueryUtil.getResult(RegistryConstants.XSD_MEDIA_TYPE,
                    getConfigSystemRegistry(),
                    getGovernanceRegistry());
        } catch (RegistryException e) {
            log.error("An error occurred while obtaining the list of schemas.", e);
            path = new String[0];
        }
        String[] name = new String[path.length];
        boolean[] canDelete = new boolean[path.length];
        for(int i=0;i<path.length;i++){
            bean.increment();
            name[i] = CommonUtil.getResourceName(path[i]);
            if (registry.getUserRealm() != null && registry.getUserName() != null) {
                try {
                    canDelete[i] =
                            registry.getUserRealm().getAuthorizationManager().isUserAuthorized(
                                    registry.getUserName(),
                                    RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + path[i],
                                    ActionConstants.DELETE);
                } catch (UserStoreException e) {
                    canDelete[i] = false;
                }
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

                    + 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);
View Full Code Here

Examples of org.wso2.carbon.registry.core.session.UserRegistry

    public Properties getServerCryptoProperties(String privateStore, String[] trustedCertStores)
            throws Exception {
        Properties props = new Properties();

        UserRegistry govRegistry = SecurityServiceHolder.getRegistryService().
                getGovernanceSystemRegistry(((UserRegistry)registry).getTenantId());

        ServerConfiguration config = ServerConfiguration.getInstance();

        if (trustedCertStores != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.