public static boolean validMagicNumbers( final BufferedInputStream bin ) throws IOException
    {
        final List<String> validMagicBytesCollection = JiveGlobals.getListProperty( "plugins.upload.magic-number.values.expected-value", Arrays.asList( "504B0304", "504B0506", "504B0708" ) );
        for ( final String entry : validMagicBytesCollection )
        {
            final byte[] validMagicBytes = StringUtils.decodeHex( entry );
            bin.mark( validMagicBytes.length );
            try
            {
                final byte[] magicBytes = new byte[validMagicBytes.length];
                int remaining = validMagicBytes.length;
                while (remaining > 0) {
                    final int location = validMagicBytes.length - remaining;
                    final int count = bin.read(magicBytes, location, remaining);
                    if (count == -1) {
                        break;
                    }
                    remaining -= count;
                }
                if ( remaining <= 0 && Arrays.equals( validMagicBytes, magicBytes ) )
                {
                    return true;
                }
            }
            finally
            {
                bin.reset();
            }
        }

        return false;
    }
Verifies that the first few bytes of the input stream correspond to any of the known 'magic numbers' that
are known to represent a JAR archive.

This method uses the mark/reset functionality of InputStream. This ensures that the input stream is reset
back to its original position after execution of this method.

@param bin The input to read (cannot be null).
@return true if the stream first few bytes are equal to any of the known magic number sequences, otherwise false.
xmppserver/src/main/java/org/jivesoftware/openfire/container/PluginManager.java