Examples of VirtualHost


Examples of de.innovationgate.wga.config.VirtualHost

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {   
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;
       
        VirtualHost vHost = findMatchingHost(_core.getWgaConfiguration(), request);
        if (vHost != null) {
            // handle vhost

            // determine default database key
            String defaultDBKey = getDefaultDBKey(_core, vHost);
           
            String uri = httpRequest.getRequestURI();
            String[] pathElements = uri.split("/");
            if (pathElements == null || pathElements.length < 1) {
                // root url request - redirect to default database or hide db
                if (defaultDBKey != null) {
                    if (vHost.isHideDefaultDatabaseInURL()) {
                        httpRequest = new DefaultDBRequestWrapper(_core, httpRequest, defaultDBKey);
                    } else {
                        httpResponse.sendRedirect(uri + defaultDBKey);
                        return;
                    }
                }
            } else if (pathElements.length == 2 && isRootResource(vHost, pathElements[1])) {
                // handle root resource request
                VirtualResource resource = findVirtualResource(vHost, pathElements[1]);
                httpRequest.getRequestDispatcher(resource.getPath()).forward(request, response);
                return;
            } else {
                // normal db request
                String requestedDBKey = pathElements[1];
                if (vHost.isHideDefaultDatabaseInURL() && defaultDBKey != null) {
                    if (requestedDBKey.equalsIgnoreCase(defaultDBKey)) {
                        // if default db requested redirect to url without dbkey
                        URLBuilder builder = new URLBuilder(httpRequest, _core.getCharacterEncoding());
                        String path = builder.getPath().substring(httpRequest.getContextPath().length());                                      
                        builder.setPath(httpRequest.getContextPath() + path.substring(defaultDBKey.length() + 1));
                        httpResponse.sendRedirect(builder.rebuild().toString());
                        return;
                    }
                   
                    // we have to check if requestedDBKey is a valid content database - if not we use defaultDatabase
                    if (!_core.getContentdbs().containsKey(requestedDBKey.toLowerCase())) {
                        requestedDBKey = defaultDBKey;
                        httpRequest = new DefaultDBRequestWrapper(_core, httpRequest, defaultDBKey);
                    }

                }
                if (!isDBKeyAllowed(_core.getWgaConfiguration(), vHost, requestedDBKey)) {                      
                    httpResponse.sendError(HttpServletResponse.SC_NOT_FOUND, "Resource '" + requestedDBKey + "' is unknown for the requested host.");
                    _core.getLog().warn("Request from '" + request.getRemoteAddr() + "' to resource '" + uri + "' is not allowed by virtual host definition '" + vHost.getServername() + "'.");
                    return;
                }
            }
        }
       
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

                    arguments.put(keyAndValue[0], keyAndValue[1]);
                }
            }
        }

        VirtualHost virtualHost = _exchange.getParent(VirtualHost.class);
        Queue queue = MBeanUtils.findQueueFromQueueName(virtualHost, queueName);
        _exchange.createBinding(binding, queue, arguments, Collections.EMPTY_MAP);
    }
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

    }

    public void removeBinding(String queueName, String bindingKey)
            throws IOException, JMException
    {
        VirtualHost virtualHost = _exchange.getParent(VirtualHost.class);
        Queue queue = MBeanUtils.findQueueFromQueueName(virtualHost, queueName);;

        boolean deleted = false;
        for(Binding binding : _exchange.getBindings())
        {
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

            String name = inArgs.getStringValue("name");
            String type = inArgs.getStringValue("type");

            NameParser nameParser = new NameParser(name, type);
            String vhostName = nameParser.getVirtualHostName();
            VirtualHost vhost = nameParser.getVirtualHost();

            if (vhost == null)
            {
                if (vhostName == null)
                {
                    agent.raiseException(handle, "VirtualHost names for exchange and queue must match.");
                }
                else
                {
                    agent.raiseException(handle, "VirtualHost " + vhostName + " not found.");
                }
            }
            else
            {
                if (methodName.equals("create")) // method = create
                {
                    try
                    {
                        //boolean strict = inArgs.getBooleanValue("strict");
                        Map<String, Object> properties = inArgs.getValue("properties");

                        boolean durable = false;
                        Object property = properties.get("durable");
                        if (property != null && property instanceof Boolean)
                        {
                            Boolean durableProperty = (Boolean)property;
                            durable = durableProperty.booleanValue();
                            properties.remove("durable");
                        }

                        if (type.equals("exchange")) // create exchange.
                        {
/*
System.out.println("Create Exchange");
System.out.println("vhostName = " + vhostName);
System.out.println("exchange name = " + nameParser.getExchangeName());
System.out.println("properties = " + properties);
*/
                            String exchangeType = "";
                            property = properties.get("exchange-type");
                            if (property != null && property instanceof String)
                            {
                                exchangeType = property.toString();
                                properties.remove("exchange-type");
                            }

                            String alternateExchange = parseAlternateExchange(vhostName, properties);
                            if (alternateExchange != null && alternateExchange.equals("invalid"))
                            {
                                agent.raiseException(handle, "Alternate Exchange must belong to the same Virtual Host as the Exchange being added.");
                                return;
                            }

                            // TODO delete this block when adding an AlternateExchange is implemented.
                            if (alternateExchange != null)
                            {
                                agent.raiseException(handle,
                                    "Setting an Alternate Exchange on an Exchange is not yet implemented.");
                                return;
                            }

                            // Note that for Qpid 0.20 the "qpid.msg_sequence=1" and "qpid.ive=1" properties are
                            // not suppored, indeed no exchange properties seem to be supported yet.
                            vhost.createExchange(nameParser.getExchangeName(), State.ACTIVE, durable,
                                                 LifetimePolicy.PERMANENT, 0l, exchangeType, properties);
                            if (alternateExchange != null)
                            {
                                // TODO set Alternate Exchange. There doesn't seem to be a way to do this yet!!!
                            }
                        } // End of create exchange.
                        else if (type.equals("queue")) // create queue.
                        {
/*
System.out.println("Create Queue");
System.out.println("vhostName = " + vhostName);
System.out.println("queue name = " + nameParser.getQueueName());
System.out.println("properties = " + properties);
*/

                            // TODO Try to map from the QMF create queue properties to the closest equivalents on
                            // the Java Broker. Unfortunately there are a *lot* of frustrating little differences.


                            String alternateExchange = parseAlternateExchange(vhostName, properties);
                            if (alternateExchange != null && alternateExchange.equals("invalid"))
                            {
                                agent.raiseException(handle, "Alternate Exchange must belong to the same Virtual Host as the Queue being added.");
                                return;
                            }

                            // I don't *think* that it make sense to allow setting exclusive or autoDelete to
                            // a queue created from config.
                            Queue queue = vhost.createQueue(nameParser.getQueueName(), State.ACTIVE, durable, false,
                                                            LifetimePolicy.PERMANENT, 0l, properties);

                            // Set the queue's alternateExchange, which is just a little bit involved......
                            // The queue.setAttribute() method needs an org.apache.qpid.server.model.Exchange instance
                            // not just a name, so we look up org.apache.qpid.server.qmf2.agentdata.Exchange by ID
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

        else if (child instanceof Connection)
        {
            if (!agentConnection && !_objects.containsKey(child))
            {
                // If the parent object is the default vhost set it to null so that the Connection ignores it.
                VirtualHost vhost = (object.getName().equals(_defaultVirtualHost)) ? null : (VirtualHost)object;
                data = new org.apache.qpid.server.qmf2.agentdata.Connection(vhost, (Connection)child);
                _objects.put(child, data);

                // Raise a Client Connect Event.
                _agent.raiseEvent(((org.apache.qpid.server.qmf2.agentdata.Connection)data).createClientConnectEvent());
            }
            agentConnection = false; // Only ignore the first Connection, which is the one from the Agent.
        }
        else if (child instanceof Session)
        {
            if (!_objects.containsKey(child))
            {
                QmfAgentData ref = _objects.get(object); // Get the Connection QmfAgentData so we can get connectionRef.
                if (ref != null)
                {
                    data = new org.apache.qpid.server.qmf2.agentdata.Session((Session)child, ref.getObjectId());
                    _objects.put(child, data);
                }
            }
        }
        else if (child instanceof Exchange)
        {
            if (!_objects.containsKey(child))
            {
                // If the parent object is the default vhost set it to null so that the Connection ignores it.
                VirtualHost vhost = (object.getName().equals(_defaultVirtualHost)) ? null : (VirtualHost)object;
                data = new org.apache.qpid.server.qmf2.agentdata.Exchange(vhost, (Exchange)child);
                _objects.put(child, data);

                // Raise an Exchange Declare Event.
                _agent.raiseEvent(((org.apache.qpid.server.qmf2.agentdata.Exchange)data).createExchangeDeclareEvent());

            }
        }
        else if (child instanceof Queue)
        {
            if (!_objects.containsKey(child))
            {
                // If the parent object is the default vhost set it to null so that the Connection ignores it.
                VirtualHost vhost = (object.getName().equals(_defaultVirtualHost)) ? null : (VirtualHost)object;
                data = new org.apache.qpid.server.qmf2.agentdata.Queue(vhost, (Queue)child);
                _objects.put(child, data);

                // Raise a Queue Declare Event.
                _agent.raiseEvent(((org.apache.qpid.server.qmf2.agentdata.Queue)data).createQueueDeclareEvent());
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

            throw new IllegalArgumentException("Invalid path is specified");
        }
        String vhostName = pathInfoElements[0];
        String queueName = pathInfoElements[1];

        VirtualHost vhost = null;

        for(VirtualHost vh : getBroker().getVirtualHosts())
        {
            if(vh.getName().equals(vhostName))
            {
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

        when(mockExchange2.getName()).thenReturn("exchange2");

        Exchange mockExchange3 = mock(Exchange.class);
        when(mockExchange3.getName()).thenReturn("exchange3");

        VirtualHost mockVirtualHost = mock(VirtualHost.class);
        when(mockVirtualHost.getExchanges()).thenReturn(Arrays.asList(new Exchange[] {mockExchange1, mockExchange2, mockExchange3}));
        when(_mockQueue.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);

        _queueMBean.setAlternateExchange("exchange2");
        verify(_mockQueue).setAttribute(Queue.ALTERNATE_EXCHANGE, null, mockExchange2);
    }
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

    public void testSetAlternateExchangeWithUnknownExchangeName() throws Exception
    {
        Exchange mockExchange = mock(Exchange.class);
        when(mockExchange.getName()).thenReturn("exchange1");

        VirtualHost mockVirtualHost = mock(VirtualHost.class);
        when(mockVirtualHost.getExchanges()).thenReturn(Collections.singletonList(mockExchange));
        when(_mockQueue.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);

        try
        {
            _queueMBean.setAlternateExchange("notknown");
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

        when(_mockVirtualHostMBean.getRegistry()).thenReturn(_mockManagedObjectRegistry);

        _mockQueue1 = createMockQueue(QUEUE1_NAME);
        _mockQueue2 = createMockQueue(QUEUE2_NAME);

        VirtualHost mockVirtualHost = mock(VirtualHost.class);
        when(mockVirtualHost.getQueues()).thenReturn(Arrays.asList(new Queue[] {_mockQueue1, _mockQueue2}));
        when(_mockExchange.getParent(VirtualHost.class)).thenReturn(mockVirtualHost);

        _exchangeMBean = new ExchangeMBean(_mockExchange, _mockVirtualHostMBean);

        _mockHeadersExchange = mock(Exchange.class);
View Full Code Here

Examples of org.apache.qpid.server.model.VirtualHost

            try
            {
                AMQManagedObject mbean;
                if(child instanceof VirtualHost)
                {
                    VirtualHost vhostChild = (VirtualHost)child;
                    mbean = new VirtualHostMBean(vhostChild, _objectRegistry);
                }
                else if(child instanceof PasswordCredentialManagingAuthenticationProvider)
                {
                    mbean = new UserManagementMBean((PasswordCredentialManagingAuthenticationProvider) child, _objectRegistry);
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.