Outputs an access denied message.

@param out
the output stream to send the message to
@param message
the message to send
177072
private void denyAccess(HttpServletResponse response, String message)
            throws IOException {
        StringBuilder sb = new StringBuilder();
        sb.append("Fedora: 403 ").append(message.toUpperCase());

        response.reset();
        response.setStatus(HttpServletResponse.SC_FORBIDDEN);
        response.setContentType("text/plain");
        response.setContentLength(sb.length());
        ServletOutputStream out = response.getOutputStream();
        out.write(sb.toString().getBytes());
        out.flush();
        out.close();
    }
847064
public void write(OutputStream out)throws SocksException,
                                             IOException{
     if(data == null){
       Socks5Message msg;

       if(addrType == SOCKS_ATYP_DOMAINNAME)
          msg = new Socks5Message(command,host,port);
       else{
          if(ip == null){
             try{
               ip = InetAddress.getByName(host);
             }catch(UnknownHostException uh_ex){
               throw new SocksException(Proxy.SOCKS_JUST_ERROR);
             }
          }
          msg = new Socks5Message(command,ip,port);
       }
       data = msg.data;
     }
     out.write(data);
   }
768951
public final void dispatch( AbstractMessage message ) throws JMSException
    {
        // Security
        LocalConnection conn = (LocalConnection)getConnection();
        if (conn.isSecurityEnabled())
        {
            Destination destination = message.getJMSDestination();
            if (destination instanceof Queue)
            {
                String queueName = ((Queue)destination).getQueueName();
                if (conn.isRegisteredTemporaryQueue(queueName))
                {
                    // OK, temporary destination
                }
                else
                if (queueName.equals(FFMQConstants.ADM_REQUEST_QUEUE))
                {
                    conn.checkPermission(Resource.SERVER, Action.REMOTE_ADMIN);
                }
                else
                if (queueName.equals(FFMQConstants.ADM_REPLY_QUEUE))
                {
                    // Only the internal admin thread can produce on this queue
                    if (conn.getSecurityContext() != null)
                        throw new FFMQException("Access denied to administration queue "+queueName,"ACCESS_DENIED");
                }
                else
                {
                    // Standard queue
                    conn.checkPermission(destination,Action.PRODUCE);
                }
            }
            else
            if (destination instanceof Topic)
            {
                String topicName = ((Topic)destination).getTopicName();
                if (conn.isRegisteredTemporaryTopic(topicName))
                {
                    // OK, temporary destination
                }
                else
                {
                    // Standard topic
                    conn.checkPermission(destination,Action.PRODUCE);   
                }
            }
            else
                throw new InvalidDestinationException("Unsupported destination : "+destination);
        }
        
        if (debugEnabled)
            log.debug(this+" [PUT] in "+message.getJMSDestination()+" - "+message);
        
        externalAccessLock.readLock().lock();
    	try
        {
            checkNotClosed();
            
            pendingPuts.add(message);
            
        	if (!transacted)
        		commitUpdates(false, null, true); // FIXME Async commit ?
        }
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
594201
public void sendMessage(String message) {
        EventBuilder eventBuilder = new EventBuilder().withMessage(message)
            .withLevel(Event.Level.INFO);
        sendEvent(eventBuilder);
    }
551865
@Override
    protected void outputPass() {
        if(!prototype.isOutputSupported())
            return;

        // take a snapshot of the current container state.
        final LinkedList<Object> toOutput = new LinkedList<Object>(instances.keySet());

        Executor executorService = null;
        Semaphore taskLock = null;
        executorService = super.getOutputExecutorService();
        if(executorService != null)
            taskLock = new Semaphore(outputConcurrency);

        // This keeps track of the number of concurrently running
        // output tasks so that this method can wait until they're
        // all done to return.
        //
        // It's also used as a condition variable signaling on its
        // own state changes.
        final AtomicLong numExecutingOutputs = new AtomicLong(0);

        // keep going until all of the outputs have been invoked
        while(toOutput.size() > 0 && isRunning.get()) {
            for(final Iterator<Object> iter = toOutput.iterator(); iter.hasNext();) {
                final Object key = iter.next();

                final WorkingPlaceholder wp = new WorkingPlaceholder();
                // we're going to hold up all incomming message to this mp
                wp.mailbox.getAndSet(null); // this blocks other threads from
                                            // dropping messages in the mailbox

                final WorkingPlaceholder alreadyThere = working.putIfAbsent(key, wp); // try to get a lock
                if(alreadyThere == null) { // we got it the lock
                    final Object instance = instances.get(key);

                    if(instance != null) {
                        final Semaphore taskSepaphore = taskLock;

                        // This task will release the wrapper's lock.
                        final Runnable task = new Runnable() {

                            @Override
                            public void run() {
                                final List<KeyedMessageWithType> response;
                                try {
                                    if(isRunning.get())
                                        response = invokeOperation(instance, Operation.output, null);
                                    else
                                        response = null;
                                } finally {
                                    working.remove(key); // releases this back to the world

                                    // this signals that we're done.
                                    synchronized(numExecutingOutputs) {
                                        numExecutingOutputs.decrementAndGet();
                                        numExecutingOutputs.notifyAll();
                                    }
                                    if(taskSepaphore != null)
                                        taskSepaphore.release();
                                }

                                if(response != null) {
                                    try {
                                        dispatcher.dispatch(response);
                                    } catch(final Exception de) {
                                        if(isRunning.get())
                                            LOGGER.warn("Failed on subsequent dispatch of " + response + ": " + de.getLocalizedMessage());
                                    }
                                }
                            }
                        };

                        synchronized(numExecutingOutputs) {
                            numExecutingOutputs.incrementAndGet();
                        }

                        if(executorService != null) {
                            try {
                                taskSepaphore.acquire();
                                executorService.execute(task);
                            } catch(final RejectedExecutionException e) {
                                working.remove(key); // we never got into the run so we need to release the lock
                                // this may happen because of a race condition between the
                                taskSepaphore.release();
                            } catch(final InterruptedException e) {
                                // this can happen while blocked in the semaphore.acquire.
                                // if we're no longer running we should just get out
                                // of here.
                                //
                                // Not releasing the taskSepaphore assumes the acquire never executed.
                                // if (since) the acquire never executed we also need to release the
                                // wrapper lock or that Mp will never be usable again.
                                working.remove(key); // we never got into the run so we need to release the lock
                            }
                        } else
                            task.run();

                        iter.remove();

                    } else {
                        working.remove(key);
                        LOGGER.warn("There was an attempt to evict a non-existent Mp for key " + SafeString.objectDescription(key));
                    }
                } // didn't get the lock
            } // loop over every mp
        } // end while there are still Mps that haven't had output invoked.

        // =======================================================
        // now make sure all of the running tasks have completed
        synchronized(numExecutingOutputs) {
            while(numExecutingOutputs.get() > 0) {
                try {
                    numExecutingOutputs.wait();
                } catch(final InterruptedException e) {
                    // if we were interupted for a shutdown then just stop
                    // waiting for all of the threads to finish
                    if(!isRunning.get())
                        break;
                    // otherwise continue checking.
                }
            }
        }
        // =======================================================

    }
324978
public void write(OutputStream out) throws IOException
    {
        if (log.isTraceEnabled())
            log.trace("AJP13 snd: "+this.toString(64));
        // System.err.println(Thread.currentThread()+" AJP13 snd
        // "+this.toString());
        out.write(_buf,0,_bytes);
    }
816523
protected function accessDeniedException(Request $request, Response $response, $message = 'Access denied.')
    {
        return new AccessDeniedException($request, $response, $message);
    }
604186
protected boolean isSendAllowed(String message, List<?> arguments) {
        // check internal handlers first
        for (ISharedObjectSecurity handler : securityHandlers) {
            if (!handler.isSendAllowed(this, message, arguments)) {
                return false;
            }
        }
        // check global SO handlers next
        final Set<ISharedObjectSecurity> handlers = getSecurityHandlers();
        if (handlers == null) {
            return true;
        }
        for (ISharedObjectSecurity handler : handlers) {
            if (!handler.isSendAllowed(this, message, arguments)) {
                return false;
            }
        }
        return true;
    }
1097680
public void handleMessage(T message) throws Fault {
        String flowId = FlowIdHelper.getFlowId(message);

        if (flowId == null) {
            flowId = FlowIdProtocolHeaderCodec.readFlowId(message);
        }

        if (flowId == null) {
            flowId = FlowIdSoapCodec.readFlowId(message);
        }

        if (flowId == null) {
             Exchange ex = message.getExchange();
        if (null!=ex){
        Message reqMsg = ex.getOutMessage();
             if ( null != reqMsg) {
                 flowId = FlowIdHelper.getFlowId(reqMsg);
                 if ( null != flowId) {
                 LOG.fine("Using FlowId '" + flowId + "' from exchange."); 
                 }
             }
        }
        }

        if (flowId != null) {
            LOG.fine("FlowId '" + flowId + "' found in incoming message.");
        } else {
            flowId = ContextUtils.generateUUID();
            LOG.fine("No flowId found in incoming message! Generate new flowId " + flowId);
        }

        FlowIdHelper.setFlowId(message, flowId);
    }
454493
public static void printVerboseMessage(final String message, final Logger logger) {
        try {
            if (JPService.getProperty(JPVerbose.class).getValue()) {
                logger.info(message);
            } else {
                logger.debug(message);
            }
        } catch (final JPServiceException ex) {
            logger.info(message);
            ExceptionPrinter.printHistory("Could not access verbose java property!", ex, logger);
        }
    }
1241083
private void output(File outFile) throws FileNotFoundException {
    System.out.println("Printing to " + outFile.toString());
    PrintStream out = new PrintStream(outFile);
    root.output(out, null);
    out.close();
  }
764156
public void debug(String message, Object... args) {
    if (isDebugEnabled()) {
      debug(String.format(message, args), getThrowable(args));
    }
  }
868358
public static void assertTrue(boolean condition, String message) {
		if (imp != null && !condition) {
			imp.assertFailed(message);
		}
	}
1228213
@Override
    protected void outputPass() {
        if(!prototype.isOutputSupported())
            return;

        // take a snapshot of the current container state.
        final LinkedList<Object> toOutput = new LinkedList<Object>(instances.keySet());

        final Executor executorService = getOutputExecutorService();
        final Semaphore taskLock = (executorService != null) ? new Semaphore(outputConcurrency) : null;

        // This keeps track of the number of concurrently running
        // output tasks so that this method can wait until they're
        // all done to return.
        //
        // It's also used as a condition variable signaling on its
        // own state changes.
        final AtomicLong numExecutingOutputs = new AtomicLong(0);

        final MutRef<WorkingQueueHolder> mref = new MutRef<>();

        // keep going until all of the outputs have been invoked
        while(toOutput.size() > 0 && isRunning.get()) {
            for(final Iterator<Object> iter = toOutput.iterator(); iter.hasNext();) {
                final Object key = iter.next();

                final InstanceWrapper wrapper = instances.get(key);

                if(wrapper != null) { // if the MP still exists
                    final WorkingQueueHolder mailbox = setIfAbsent(wrapper.mailbox, () -> mref.set(new WorkingQueueHolder(true)));
                    if(mailbox == null) { // this means I got it.
                        // it was created locked so no one else will be able to drop messages in the mailbox.
                        final Semaphore taskSepaphore = taskLock;

                        // This task will release the wrapper's lock.
                        final Runnable task = new Runnable() {

                            @Override
                            public void run() {
                                try {
                                    if(isRunning.get())
                                        invokeOperation(wrapper.instance, Operation.output, null);
                                } finally {
                                    wrapper.mailbox.set(null); // releases this back to the world

                                    // this signals that we're done.
                                    synchronized(numExecutingOutputs) {
                                        numExecutingOutputs.decrementAndGet();
                                        numExecutingOutputs.notifyAll();
                                    }
                                    if(taskSepaphore != null)
                                        taskSepaphore.release();
                                }
                            }
                        };

                        synchronized(numExecutingOutputs) {
                            numExecutingOutputs.incrementAndGet();
                        }

                        if(executorService != null) {
                            try {
                                taskSepaphore.acquire();
                                executorService.execute(task);
                            } catch(final RejectedExecutionException e) {
                                wrapper.mailbox.set(null); // we never got into the run so we need to release the lock
                                // this may happen because of a race condition between the
                                taskSepaphore.release();
                            } catch(final InterruptedException e) {
                                // this can happen while blocked in the semaphore.acquire.
                                // if we're no longer running we should just get out
                                // of here.
                                //
                                // Not releasing the taskSepaphore assumes the acquire never executed.
                                // if (since) the acquire never executed we also need to release the
                                // wrapper lock or that Mp will never be usable again.
                                wrapper.mailbox.set(null); // we never got into the run so we need to release the lock
                            }
                        } else
                            task.run();

                        iter.remove();

                    } // didn't get the lock
                } else { // end if mp exists. Otherwise the mp is already gone.
                    iter.remove();
                    LOGGER.warn("There was an attempt to output a non-existent Mp for key " + SafeString.objectDescription(key));
                }
            } // loop over every mp
        } // end while there are still Mps that haven't had output invoked.

        // =======================================================
        // now make sure all of the running tasks have completed
        synchronized(numExecutingOutputs) {
            while(numExecutingOutputs.get() > 0) {
                try {
                    numExecutingOutputs.wait();
                } catch(final InterruptedException e) {
                    // if we were interupted for a shutdown then just stop
                    // waiting for all of the threads to finish
                    if(!isRunning.get())
                        break;
                    // otherwise continue checking.
                }
            }
        }
        // =======================================================
    }
964969
public static void error(Object... message) {
        StringBuilder builder = new StringBuilder(APP_ERROR);
        for (Object object : message) {
            builder.append(object.toString());
        }
        errorStream.println(builder.toString());
    }
504034
public void printUsage(OutputStream out, String name, boolean showHidden) {
        printUsage(new PrintWriter(new OutputStreamWriter(out, UTF_8)), name, showHidden);
    }
594257
protected void sendMessage(DataOutputStream outputStream, Message message) throws IOException {
        long startNs = System.nanoTime();
        ProtoUtils.writeMessage(outputStream, message);
        if(streamStats != null) {
            streamStats.reportNetworkTime(operation,
                                          Utils.elapsedTimeNs(startNs, System.nanoTime()));
        }
    }