Package org.apache.sshd.common.mac
Enum BuiltinMacs
- java.lang.Object
-
- java.lang.Enum<BuiltinMacs>
-
- org.apache.sshd.common.mac.BuiltinMacs
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<BuiltinMacs>
,java.util.function.Supplier<Mac>
,AlgorithmNameProvider
,BuiltinFactory<Mac>
,Factory<Mac>
,MacFactory
,MacInformation
,NamedFactory<Mac>
,NamedResource
,OptionalFeature
public enum BuiltinMacs extends java.lang.Enum<BuiltinMacs> implements MacFactory
Provides easy access to the currently implemented macs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BuiltinMacs.Constants
static class
BuiltinMacs.ParseResult
-
Enum Constant Summary
Enum Constants Enum Constant Description hmacmd5
Deprecated.hmacmd596
Deprecated.hmacsha1
hmacsha196
Deprecated.hmacsha1etm
hmacsha256
See RFC 6668hmacsha256etm
hmacsha512
See RFC 6668hmacsha512etm
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
algorithm
private int
bsize
private int
defbsize
private static java.util.Map<java.lang.String,MacFactory>
EXTENSIONS
private java.lang.String
factoryName
static java.util.Set<BuiltinMacs>
VALUES
-
Fields inherited from interface org.apache.sshd.common.NamedResource
BY_NAME_COMPARATOR, NAME_EXTRACTOR
-
Fields inherited from interface org.apache.sshd.common.OptionalFeature
FALSE, TRUE
-
-
Constructor Summary
Constructors Modifier Constructor Description private
BuiltinMacs(java.lang.String factoryName, java.lang.String algorithm, int bsize, int defbsize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Mac
create()
static BuiltinMacs
fromFactory(NamedFactory<Mac> factory)
static BuiltinMacs
fromFactoryName(java.lang.String name)
static BuiltinMacs
fromString(java.lang.String s)
java.lang.String
getAlgorithm()
int
getBlockSize()
int
getDefaultBlockSize()
java.lang.String
getName()
static java.util.NavigableSet<MacFactory>
getRegisteredExtensions()
boolean
isSupported()
static BuiltinMacs.ParseResult
parseMacsList(java.lang.String macs)
static BuiltinMacs.ParseResult
parseMacsList(java.lang.String... macs)
static BuiltinMacs.ParseResult
parseMacsList(java.util.Collection<java.lang.String> macs)
static void
registerExtension(MacFactory extension)
Registered aNamedFactory
to be available besides the built-in ones when parsing configurationstatic MacFactory
resolveFactory(java.lang.String name)
java.lang.String
toString()
static MacFactory
unregisterExtension(java.lang.String name)
Unregisters specified extensionstatic BuiltinMacs
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static BuiltinMacs[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
-
Methods inherited from interface org.apache.sshd.common.mac.MacInformation
isEncryptThenMac
-
-
-
-
Enum Constant Detail
-
hmacmd5
@Deprecated public static final BuiltinMacs hmacmd5
Deprecated.- See Also:
- SSHD-1004
-
hmacmd596
@Deprecated public static final BuiltinMacs hmacmd596
Deprecated.- See Also:
- SSHD-1004
-
hmacsha1
public static final BuiltinMacs hmacsha1
-
hmacsha1etm
public static final BuiltinMacs hmacsha1etm
-
hmacsha196
@Deprecated public static final BuiltinMacs hmacsha196
Deprecated.- See Also:
- SSHD-1004
-
hmacsha256
public static final BuiltinMacs hmacsha256
See RFC 6668
-
hmacsha256etm
public static final BuiltinMacs hmacsha256etm
-
hmacsha512
public static final BuiltinMacs hmacsha512
See RFC 6668
-
hmacsha512etm
public static final BuiltinMacs hmacsha512etm
-
-
Field Detail
-
VALUES
public static final java.util.Set<BuiltinMacs> VALUES
-
EXTENSIONS
private static final java.util.Map<java.lang.String,MacFactory> EXTENSIONS
-
factoryName
private final java.lang.String factoryName
-
algorithm
private final java.lang.String algorithm
-
defbsize
private final int defbsize
-
bsize
private final int bsize
-
-
Method Detail
-
values
public static BuiltinMacs[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (BuiltinMacs c : BuiltinMacs.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static BuiltinMacs valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getName
public final java.lang.String getName()
- Specified by:
getName
in interfaceNamedResource
- Returns:
- The resource name
-
getAlgorithm
public final java.lang.String getAlgorithm()
- Specified by:
getAlgorithm
in interfaceAlgorithmNameProvider
-
getBlockSize
public final int getBlockSize()
- Specified by:
getBlockSize
in interfaceMacInformation
- Returns:
- MAC output block size in bytes - may be less than the default - e.g., MD5-96
-
getDefaultBlockSize
public final int getDefaultBlockSize()
- Specified by:
getDefaultBlockSize
in interfaceMacInformation
- Returns:
- The "natural" MAC block size in bytes
-
isSupported
public final boolean isSupported()
- Specified by:
isSupported
in interfaceOptionalFeature
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Enum<BuiltinMacs>
-
registerExtension
public static void registerExtension(MacFactory extension)
Registered aNamedFactory
to be available besides the built-in ones when parsing configuration- Parameters:
extension
- The factory to register- Throws:
java.lang.IllegalArgumentException
- if factory instance isnull
, or overrides a built-in one or overrides another registered factory with the same name (case insensitive).
-
getRegisteredExtensions
public static java.util.NavigableSet<MacFactory> getRegisteredExtensions()
- Returns:
- A
NavigableSet
of the currently registered extensions, sorted according to the factory name (case insensitive)
-
unregisterExtension
public static MacFactory unregisterExtension(java.lang.String name)
Unregisters specified extension- Parameters:
name
- The factory name - ignored ifnull
/empty- Returns:
- The registered extension -
null
if not found
-
fromString
public static BuiltinMacs fromString(java.lang.String s)
- Parameters:
s
- TheEnum
's name - ignored ifnull
/empty- Returns:
- The matching
BuiltinMacs
whoseEnum.name()
matches (case insensitive) the provided argument -null
if no match
-
fromFactory
public static BuiltinMacs fromFactory(NamedFactory<Mac> factory)
- Parameters:
factory
- TheNamedFactory
for the MAC - ignored ifnull
- Returns:
- The matching
BuiltinMacs
whose factory name matches (case insensitive) the digest factory name - See Also:
fromFactoryName(String)
-
fromFactoryName
public static BuiltinMacs fromFactoryName(java.lang.String name)
- Parameters:
name
- The factory name - ignored ifnull
/empty- Returns:
- The matching
BuiltinMacs
whose factory name matches (case insensitive) the provided name -null
if no match
-
parseMacsList
public static BuiltinMacs.ParseResult parseMacsList(java.lang.String macs)
- Parameters:
macs
- A comma-separated list of MACs' names - ignored ifnull
/empty- Returns:
- A
BuiltinMacs.ParseResult
containing the successfully parsed factories and the unknown ones. Note: it is up to caller to ensure that the lists do not contain duplicates
-
parseMacsList
public static BuiltinMacs.ParseResult parseMacsList(java.lang.String... macs)
-
parseMacsList
public static BuiltinMacs.ParseResult parseMacsList(java.util.Collection<java.lang.String> macs)
-
resolveFactory
public static MacFactory resolveFactory(java.lang.String name)
- Parameters:
name
- The factory name- Returns:
- The factory or
null
if it is neither a built-in one or a registered extension
-
-