![JAR search and dependency download from the Maven repository](/logo.png)
io.imunity.vaadin.auth.services.layout.configuration.elements.HeaderConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unity-server-vaadin-authentication Show documentation
Show all versions of unity-server-vaadin-authentication Show documentation
Vaadin login view and components
/*
* Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
* See LICENCE.txt file for licensing information.
*/
package io.imunity.vaadin.auth.services.layout.configuration.elements;
import com.google.common.base.Objects;
import io.imunity.vaadin.auth.AuthnOptionsColumns;
import io.imunity.vaadin.endpoint.common.VaadinEndpointProperties;
import pl.edu.icm.unity.base.i18n.I18nString;
import pl.edu.icm.unity.base.message.MessageSource;
import java.util.Optional;
import java.util.Properties;
import java.util.function.Supplier;
public class HeaderConfig implements AuthnElementConfiguration
{
public final I18nString headerText;
public HeaderConfig(I18nString headerText)
{
this.headerText = headerText;
}
@Override
public int hashCode()
{
return Objects.hashCode(headerText);
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (getClass() != obj.getClass())
return false;
final HeaderConfig other = (HeaderConfig) obj;
return Objects.equal(this.headerText, other.headerText);
}
public static class Parser implements AuthnElementParser
{
private final MessageSource msg;
private final Supplier idGenerator;
public Parser(MessageSource msg, Supplier idGenerator)
{
this.msg = msg;
this.idGenerator = idGenerator;
}
@Override
public Optional getConfigurationElement(
VaadinEndpointProperties properties, String specEntry)
{
if (!specEntry.startsWith(AuthnOptionsColumns.SPECIAL_ENTRY_HEADER))
return Optional.empty();
String key = specEntry.substring(AuthnOptionsColumns.SPECIAL_ENTRY_HEADER.length());
I18nString message = key.isEmpty() ? new I18nString()
: SeparatorConfig.Parser
.resolveSeparatorMessage(key.substring(1), properties, msg);
return Optional.of(new HeaderConfig(message));
}
@Override
public PropertiesRepresentation toProperties(HeaderConfig element)
{
String key = AuthnOptionsColumns.SPECIAL_ENTRY_HEADER;
Properties raw = new Properties();
if (element.headerText != null && !element.headerText.isEmpty())
{
String id = idGenerator.get();
element.headerText.toProperties(raw,
VaadinEndpointProperties.PREFIX
+ VaadinEndpointProperties.AUTHN_OPTION_LABEL_PFX + id + "."
+ VaadinEndpointProperties.AUTHN_OPTION_LABEL_TEXT,
msg);
key += "_" + id;
}
return new PropertiesRepresentation(key, raw);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy