use of org.infinispan.server.hotrod.configuration.Attribute in project infinispan by infinispan.
the class HotRodServerConfigurationParser method parseHotRodConnector.
private void parseHotRodConnector(ConfigurationReader reader, ServerConfigurationBuilder serverBuilder, HotRodServerConfigurationBuilder builder) {
boolean dedicatedSocketBinding = false;
String securityRealm = null;
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeName(i));
switch(attribute) {
case EXTERNAL_HOST:
{
builder.proxyHost(value);
break;
}
case EXTERNAL_PORT:
{
builder.proxyPort(Integer.parseInt(value));
break;
}
case NAME:
{
builder.name(value);
break;
}
case SOCKET_BINDING:
{
builder.socketBinding(value);
builder.startTransport(true);
dedicatedSocketBinding = true;
break;
}
case SECURITY_REALM:
{
builder.authentication().securityRealm(value);
break;
}
case NETWORK_PREFIX_OVERRIDE:
{
builder.topologyNetworkPrefixOverride(Boolean.parseBoolean(value));
break;
}
default:
{
ServerConfigurationParser.parseCommonConnectorAttributes(reader, i, serverBuilder, builder);
}
}
}
if (!dedicatedSocketBinding) {
builder.socketBinding(serverBuilder.endpoints().current().singlePort().socketBinding()).startTransport(false);
}
while (reader.inTag()) {
Element element = Element.forName(reader.getLocalName());
switch(element) {
case TOPOLOGY_STATE_TRANSFER:
{
parseTopologyStateTransfer(reader, builder);
break;
}
case AUTHENTICATION:
{
parseAuthentication(reader, serverBuilder, builder.authentication().enable(), securityRealm);
break;
}
case ENCRYPTION:
{
if (!dedicatedSocketBinding) {
throw Server.log.cannotConfigureProtocolEncryptionUnderSinglePort();
}
parseEncryption(reader, serverBuilder, builder.encryption(), securityRealm);
break;
}
default:
{
ServerConfigurationParser.parseCommonConnectorElements(reader, builder);
}
}
}
}
use of org.infinispan.server.hotrod.configuration.Attribute in project infinispan by infinispan.
the class HotRodServerConfigurationParser method parseSasl.
private String parseSasl(ConfigurationReader reader, AuthenticationConfigurationBuilder builder) {
SaslConfigurationBuilder sasl = builder.sasl();
String serverPrincipal = null;
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeName(i));
switch(attribute) {
case SERVER_PRINCIPAL:
{
serverPrincipal = value;
break;
}
case SERVER_NAME:
{
sasl.serverName(value);
break;
}
case MECHANISMS:
{
for (String mech : reader.getListAttributeValue(i)) {
sasl.addAllowedMech(mech);
}
break;
}
case QOP:
{
for (String qop : reader.getListAttributeValue(i)) {
sasl.addQOP(qop);
}
break;
}
case STRENGTH:
{
for (String s : reader.getListAttributeValue(i)) {
sasl.addStrength(s);
}
break;
}
case POLICY:
{
for (String p : reader.getListAttributeValue(i)) {
sasl.addPolicy(p);
}
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
final EnumSet<Element> visited = EnumSet.noneOf(Element.class);
while (reader.inTag()) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case POLICY:
{
if (reader.getSchema().since(13, 0) || visited.contains(element)) {
throw ParseUtils.unexpectedElement(reader);
} else {
visited.add(element);
}
parsePolicy(reader, builder);
break;
}
case PROPERTIES:
{
// JSON/YAML map properties to attributes
for (int i = 0; i < reader.getAttributeCount(); i++) {
sasl.addProperty(reader.getAttributeName(i), reader.getAttributeValue(i));
}
ParseUtils.requireNoContent(reader);
break;
}
case PROPERTY:
{
sasl.addProperty(ParseUtils.requireSingleAttribute(reader, Attribute.NAME), reader.getElementText());
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
return serverPrincipal;
}
use of org.infinispan.server.hotrod.configuration.Attribute in project infinispan by infinispan.
the class HotRodServerConfigurationParser method parseEncryption.
private void parseEncryption(ConfigurationReader reader, ServerConfigurationBuilder serverBuilder, EncryptionConfigurationBuilder encryption, String securityRealm) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeName(i));
switch(attribute) {
case REQUIRE_SSL_CLIENT_AUTH:
{
encryption.requireClientAuth(Boolean.parseBoolean(value));
break;
}
case SECURITY_REALM:
{
securityRealm = value;
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (securityRealm == null) {
throw Server.log.encryptionWithoutSecurityRealm();
} else {
encryption.realm(securityRealm).sslContext(serverBuilder.serverSSLContextSupplier(securityRealm));
}
while (reader.inTag(Element.ENCRYPTION)) {
Element element = Element.forName(reader.getLocalName());
switch(element) {
case SNI:
{
if (reader.getAttributeCount() > 0) {
parseSni(reader, serverBuilder, encryption.addSni());
}
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
}
use of org.infinispan.server.hotrod.configuration.Attribute in project infinispan by infinispan.
the class HotRodServerConfigurationParser method parseTopologyStateTransfer.
private void parseTopologyStateTransfer(ConfigurationReader reader, HotRodServerConfigurationBuilder builder) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeName(i));
switch(attribute) {
case LOCK_TIMEOUT:
{
builder.topologyLockTimeout(Long.parseLong(value));
break;
}
case AWAIT_INITIAL_RETRIEVAL:
{
builder.topologyAwaitInitialTransfer(Boolean.parseBoolean(value));
break;
}
case REPLICATION_TIMEOUT:
{
builder.topologyReplTimeout(Long.parseLong(value));
break;
}
case LAZY_RETRIEVAL:
{
if (reader.getSchema().since(11, 0))
Server.log.warnHotRodLazyRetrievalDeprecated();
builder.topologyStateTransfer(!Boolean.parseBoolean(value));
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
ParseUtils.requireNoContent(reader);
}
use of org.infinispan.server.hotrod.configuration.Attribute in project infinispan by infinispan.
the class HotRodServerConfigurationParser method parseAuthentication.
private void parseAuthentication(ConfigurationReader reader, ServerConfigurationBuilder serverBuilder, AuthenticationConfigurationBuilder builder, String securityRealm) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
ParseUtils.requireNoNamespaceAttribute(reader, i);
String value = reader.getAttributeValue(i);
Attribute attribute = Attribute.forName(reader.getAttributeName(i));
switch(attribute) {
case SECURITY_REALM:
{
securityRealm = value;
break;
}
default:
{
throw ParseUtils.unexpectedAttribute(reader, i);
}
}
}
if (securityRealm == null) {
securityRealm = serverBuilder.endpoints().current().securityRealm();
}
if (securityRealm == null) {
throw Server.log.authenticationWithoutSecurityRealm();
}
// Automatically set the digest realm name. It can be overridden by the user
builder.addMechProperty(WildFlySasl.REALM_LIST, securityRealm);
String serverPrincipal = null;
while (reader.inTag()) {
Element element = Element.forName(reader.getLocalName());
switch(element) {
case SASL:
{
serverPrincipal = parseSasl(reader, builder);
break;
}
default:
{
throw ParseUtils.unexpectedElement(reader);
}
}
}
builder.securityRealm(securityRealm);
builder.serverAuthenticationProvider(new ElytronSASLAuthenticationProvider(securityRealm, serverPrincipal, builder.sasl().mechanisms()));
}
Aggregations