com.enonic.xp.lib.portal.url.LoginUrlHandler Maven / Gradle / Ivy
package com.enonic.xp.lib.portal.url;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.google.common.collect.Multimap;
import com.enonic.xp.portal.url.IdentityUrlParams;
import com.enonic.xp.security.IdProviderKey;
import com.enonic.xp.web.vhost.VirtualHost;
import com.enonic.xp.web.vhost.VirtualHostHelper;
public final class LoginUrlHandler
extends AbstractUrlHandler
{
private static final Set VALID_URL_PROPERTY_KEYS =
new HashSet<>( Arrays.asList( "idProvider", "redirect", "contextPath", "type", "params" ) );
@Override
protected String buildUrl( final Multimap map )
{
final IdentityUrlParams params = new IdentityUrlParams().
portalRequest( request ).
idProviderFunction( "login" ).
idProviderKey( retrieveIdProviderKey() ).
setAsMap( map );
return this.urlService.identityUrl( params );
}
@Override
protected boolean isValidParam( final String param )
{
return VALID_URL_PROPERTY_KEYS.contains( param );
}
private IdProviderKey retrieveIdProviderKey()
{
final VirtualHost virtualHost = VirtualHostHelper.getVirtualHost( request.getRawRequest() );
if ( virtualHost != null )
{
return virtualHost.getDefaultIdProviderKey();
}
return null;
}
}