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 DigestWWWAuthenticateToken implements HeaderToken {
REALM(Headers.REALM, true),
DOMAIN(Headers.DOMAIN, true),
NONCE(Headers.NONCE, true),
OPAQUE(Headers.OPAQUE, true),
STALE(Headers.STALE, false),
ALGORITHM(Headers.ALGORITHM, false),
MESSAGE_QOP(Headers.QOP, true),
AUTH_PARAM(Headers.AUTH_PARAM, false);
private static final HeaderTokenParser<DigestWWWAuthenticateToken> TOKEN_PARSER;
static {
Map<String, DigestWWWAuthenticateToken> expected = new LinkedHashMap<>(
DigestWWWAuthenticateToken.values().length);
for (DigestWWWAuthenticateToken current : DigestWWWAuthenticateToken.values()) {
expected.put(current.getName(), current);
}
TOKEN_PARSER = new HeaderTokenParser<>(Collections.unmodifiableMap(expected));
}
private final String name;
private final boolean quoted;
DigestWWWAuthenticateToken(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<DigestWWWAuthenticateToken, String> (final String header) {
return TOKEN_PARSER.parseHeader(header);
}
}