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;
    }
@Test
    public void testJARMagicBytes() throws Exception
    {
        // Setup test fixture.
        try (final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("hello.jar")) {
            assert inputStream != null;
            try (final BufferedInputStream in = new BufferedInputStream(inputStream)) {

                // Execute system under test
                final boolean result = PluginManager.validMagicNumbers( in );

                // Verify results.
                assertTrue( result );
            }
        }
    }