@Test(expectedExceptions = MantaEncryptionException.class) public void nullEncryptionTypeWontValidate() { EncryptionType.validateEncryptionTypeIsSupported(null); }
@SuppressWarnings({"Duplicates"}) public static void validateEncryptionTypeIsSupported(final String encryptionType) { if (encryptionType == null) { String msg = "Invalid encryption type identifier must not be null"; throw new MantaEncryptionException(msg); } if (StringUtils.isBlank(encryptionType)) { String msg = "Invalid encryption type identifier must not be blank"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", String.format("[%s]", encryptionType)); throw e; } final String[] parts = encryptionType.split(SEPARATOR, 2); if (parts.length != 2) { String msg = "Invalid encryption type identifier specified: missing version separator."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); throw e; } final EncryptionType type = SUPPORTED_ENCRYPTION_TYPES.get(parts[0]); if (type == null) { String msg = "Invalid encryption type identifier specified: Unknown type."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); e.setContextValue("type", parts[0]); throw e; } final int version; try { version = Integer.parseUnsignedInt(parts[1]); } catch (NumberFormatException e) { String msg = "Invalid encryption type version identifier specified."; MantaEncryptionException mcee = new MantaEncryptionException(msg, e); mcee.setContextValue("malformedEncryptionType", encryptionType); mcee.setContextValue("malformedVersionString", parts[1]); throw mcee; } if (version > type.maxVersionSupported) { String msg = "Encryption type version is greater than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } if (version < type.maxVersionSupported) { String msg = "Encryption type version is less than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } }
EncryptionType { @SuppressWarnings({"Duplicates"}) public static void validateEncryptionTypeIsSupported(final String encryptionType) { if (encryptionType == null) { String msg = "Invalid encryption type identifier must not be null"; throw new MantaEncryptionException(msg); } if (StringUtils.isBlank(encryptionType)) { String msg = "Invalid encryption type identifier must not be blank"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", String.format("[%s]", encryptionType)); throw e; } final String[] parts = encryptionType.split(SEPARATOR, 2); if (parts.length != 2) { String msg = "Invalid encryption type identifier specified: missing version separator."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); throw e; } final EncryptionType type = SUPPORTED_ENCRYPTION_TYPES.get(parts[0]); if (type == null) { String msg = "Invalid encryption type identifier specified: Unknown type."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); e.setContextValue("type", parts[0]); throw e; } final int version; try { version = Integer.parseUnsignedInt(parts[1]); } catch (NumberFormatException e) { String msg = "Invalid encryption type version identifier specified."; MantaEncryptionException mcee = new MantaEncryptionException(msg, e); mcee.setContextValue("malformedEncryptionType", encryptionType); mcee.setContextValue("malformedVersionString", parts[1]); throw mcee; } if (version > type.maxVersionSupported) { String msg = "Encryption type version is greater than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } if (version < type.maxVersionSupported) { String msg = "Encryption type version is less than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } } }
EncryptionType { @SuppressWarnings({"Duplicates"}) public static void validateEncryptionTypeIsSupported(final String encryptionType) { if (encryptionType == null) { String msg = "Invalid encryption type identifier must not be null"; throw new MantaEncryptionException(msg); } if (StringUtils.isBlank(encryptionType)) { String msg = "Invalid encryption type identifier must not be blank"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", String.format("[%s]", encryptionType)); throw e; } final String[] parts = encryptionType.split(SEPARATOR, 2); if (parts.length != 2) { String msg = "Invalid encryption type identifier specified: missing version separator."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); throw e; } final EncryptionType type = SUPPORTED_ENCRYPTION_TYPES.get(parts[0]); if (type == null) { String msg = "Invalid encryption type identifier specified: Unknown type."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); e.setContextValue("type", parts[0]); throw e; } final int version; try { version = Integer.parseUnsignedInt(parts[1]); } catch (NumberFormatException e) { String msg = "Invalid encryption type version identifier specified."; MantaEncryptionException mcee = new MantaEncryptionException(msg, e); mcee.setContextValue("malformedEncryptionType", encryptionType); mcee.setContextValue("malformedVersionString", parts[1]); throw mcee; } if (version > type.maxVersionSupported) { String msg = "Encryption type version is greater than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } if (version < type.maxVersionSupported) { String msg = "Encryption type version is less than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } } private  EncryptionType(final String name,
                           final int minVersionSupported,
                           final int maxVersionSupported); }
EncryptionType { @SuppressWarnings({"Duplicates"}) public static void validateEncryptionTypeIsSupported(final String encryptionType) { if (encryptionType == null) { String msg = "Invalid encryption type identifier must not be null"; throw new MantaEncryptionException(msg); } if (StringUtils.isBlank(encryptionType)) { String msg = "Invalid encryption type identifier must not be blank"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", String.format("[%s]", encryptionType)); throw e; } final String[] parts = encryptionType.split(SEPARATOR, 2); if (parts.length != 2) { String msg = "Invalid encryption type identifier specified: missing version separator."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); throw e; } final EncryptionType type = SUPPORTED_ENCRYPTION_TYPES.get(parts[0]); if (type == null) { String msg = "Invalid encryption type identifier specified: Unknown type."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); e.setContextValue("type", parts[0]); throw e; } final int version; try { version = Integer.parseUnsignedInt(parts[1]); } catch (NumberFormatException e) { String msg = "Invalid encryption type version identifier specified."; MantaEncryptionException mcee = new MantaEncryptionException(msg, e); mcee.setContextValue("malformedEncryptionType", encryptionType); mcee.setContextValue("malformedVersionString", parts[1]); throw mcee; } if (version > type.maxVersionSupported) { String msg = "Encryption type version is greater than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } if (version < type.maxVersionSupported) { String msg = "Encryption type version is less than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } } private  EncryptionType(final String name,
                           final int minVersionSupported,
                           final int maxVersionSupported); @SuppressWarnings({"Duplicates"}) static void validateEncryptionTypeIsSupported(final String encryptionType); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); }
EncryptionType { @SuppressWarnings({"Duplicates"}) public static void validateEncryptionTypeIsSupported(final String encryptionType) { if (encryptionType == null) { String msg = "Invalid encryption type identifier must not be null"; throw new MantaEncryptionException(msg); } if (StringUtils.isBlank(encryptionType)) { String msg = "Invalid encryption type identifier must not be blank"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", String.format("[%s]", encryptionType)); throw e; } final String[] parts = encryptionType.split(SEPARATOR, 2); if (parts.length != 2) { String msg = "Invalid encryption type identifier specified: missing version separator."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); throw e; } final EncryptionType type = SUPPORTED_ENCRYPTION_TYPES.get(parts[0]); if (type == null) { String msg = "Invalid encryption type identifier specified: Unknown type."; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("malformedEncryptionType", encryptionType); e.setContextValue("type", parts[0]); throw e; } final int version; try { version = Integer.parseUnsignedInt(parts[1]); } catch (NumberFormatException e) { String msg = "Invalid encryption type version identifier specified."; MantaEncryptionException mcee = new MantaEncryptionException(msg, e); mcee.setContextValue("malformedEncryptionType", encryptionType); mcee.setContextValue("malformedVersionString", parts[1]); throw mcee; } if (version > type.maxVersionSupported) { String msg = "Encryption type version is greater than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } if (version < type.maxVersionSupported) { String msg = "Encryption type version is less than supported"; MantaEncryptionException e = new MantaEncryptionException(msg); e.setContextValue("encryptionType", encryptionType); e.setContextValue("desiredVersion", version); e.setContextValue("minimumVersionSupported", type.minVersionSupported); e.setContextValue("maximumVersionSupported", type.maxVersionSupported); throw e; } } private  EncryptionType(final String name,
                           final int minVersionSupported,
                           final int maxVersionSupported); @SuppressWarnings({"Duplicates"}) static void validateEncryptionTypeIsSupported(final String encryptionType); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static final EncryptionType CLIENT; }