package io.undertow.security.impl;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import io.undertow.util.HeaderToken;
import io.undertow.util.HeaderTokenParser;
import io.undertow.util.Headers;
import io.undertow.util.HttpString;
public enum AuthenticationInfoToken implements HeaderToken {
NEXT_NONCE(Headers.NEXT_NONCE, true),
MESSAGE_QOP(Headers.QOP, true),
RESPONSE_AUTH(Headers.RESPONSE_AUTH, true),
CNONCE(Headers.CNONCE, true),
NONCE_COUNT(Headers.NONCE_COUNT, false);
private static final HeaderTokenParser<AuthenticationInfoToken> TOKEN_PARSER;
static {
Map<String, AuthenticationInfoToken> expected = new LinkedHashMap<>(
AuthenticationInfoToken.values().length);
for (AuthenticationInfoToken current : AuthenticationInfoToken.values()) {
expected.put(current.getName(), current);
}
TOKEN_PARSER = new HeaderTokenParser<>(Collections.unmodifiableMap(expected));
}
private final String name;
private final boolean quoted;
AuthenticationInfoToken(final HttpString name, final boolean quoted) {
this.name = name.toString();
this.quoted = quoted;
}
public String getName() {
return name;
}
public boolean isAllowQuoted() {
return quoted;
}
public static Map<AuthenticationInfoToken, String> (final String header) {
return TOKEN_PARSER.parseHeader(header);
}
}