Package org.wso2.carbon.registry.core.session

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


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

        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

        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

        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

                    + 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

    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

    private String getPrivateKeyPassword(String username) throws IOException, Exception {

        String password = null;
        int tenantId = ((UserRegistry)registry).getTenantId();
        UserRegistry govRegistry = SecurityServiceHolder.getRegistryService().
                getGovernanceSystemRegistry(tenantId);
        try {
            KeyStoreManager keyMan = KeyStoreManager.getInstance(govRegistry);
            if (govRegistry.resourceExists(SecurityConstants.KEY_STORES)) {
                Collection collection = (Collection) govRegistry.get(SecurityConstants.KEY_STORES);
                String[] ks = collection.getChildren();

                for (int i = 0; i < ks.length; i++) {

                    String fullname = ks[i];
                    //get the primary keystore, only if it is super tenant.
                    if (tenantId == 0 && fullname
                            .equals(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
                        KeyStore store = keyMan.getPrimaryKeyStore();
                        if (store.containsAlias(username)) {
                            password = keyMan.getPrimaryPrivateKeyPasssword();
                            break;
                        }
                    } else {
                        String name = fullname.substring(fullname.lastIndexOf("/") + 1);
                        KeyStore store = keyMan.getKeyStore(name);
                        if (store.containsAlias(username)) {
                            Resource resource = (Resource) govRegistry.get(ks[i]);
                            CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil();
                            String encryptedPassword = resource
                                    .getProperty(SecurityConstants.PROP_PRIVATE_KEY_PASS);
                            password = new String(cryptoUtil
                                    .base64DecodeAndDecrypt(encryptedPassword));
View Full Code Here

            gadgetUrl = gadgetUrl.split("resource")[1];
        } else {
            //GS is not hosting this gadget
            return true;
        }
        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
        if (registry == null) {
            registry = (UserRegistry) getConfigSystemRegistry();
        }
        return registry.getUserRealm().getAuthorizationManager().isUserAuthorized(user, gadgetUrl, ActionConstants.GET);
    }
View Full Code Here

            gadgetUrl = gadgetUrl.split("resource")[1];
        } else {
            //GS is not hosting this gadget
            return true;
        }
        UserRegistry registry = (UserRegistry) getConfigUserRegistry();
        if (registry == null) {
            registry = (UserRegistry) getConfigSystemRegistry();
        }
        return registry.getUserRealm().getAuthorizationManager().isUserAuthorized(user, gadgetUrl, ActionConstants.GET);
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.session.UserRegistry

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.