Keycloak - Custom form action not visible in flowWrong ordering in generated table in jpaHibernate UserType nullSafeSet - how to know if called for insert/update or selectSort ArrayList of custom Objects by propertyCan someone show me a simple working implementation of PagerSlidingTabStrip?why spill failure happens for Custom Data Type in HadoopsetText on button from another activity androidKeycloak required action check in authentiation flowIs KeyCloak authentication using Custom User Attribute possible?Why onBindViewHolder index isn't incrementing in Recycler View?keycloak to keycloak data sync

Avoiding estate tax by giving multiple gifts

Increase performance creating Mandelbrot set in python

How do I go from 300 unfinished/half written blog posts, to published posts?

How to check is there any negative term in a large list?

Would this custom Sorcerer variant that can only learn any verbal-component-only spell be unbalanced?

Integer addition + constant, is it a group?

Roman Numeral Treatment of Suspensions

How did Arya survive the stabbing?

Tiptoe or tiphoof? Adjusting words to better fit fantasy races

Can the discrete variable be a negative number?

Is `x >> pure y` equivalent to `liftM (const y) x`

Is the destination of a commercial flight important for the pilot?

Purchasing a ticket for someone else in another country?

Why escape if the_content isnt?

How to run a prison with the smallest amount of guards?

What is the difference between "behavior" and "behaviour"?

What is the best translation for "slot" in the context of multiplayer video games?

How to safely derail a train during transit?

Is there a problem with hiding "forgot password" until it's needed?

Go Pregnant or Go Home

Large drywall patch supports

How does it work when somebody invests in my business?

How do I rename a Linux host without needing to reboot for the rename to take effect?

Was Spock the First Vulcan in Starfleet?



Keycloak - Custom form action not visible in flow


Wrong ordering in generated table in jpaHibernate UserType nullSafeSet - how to know if called for insert/update or selectSort ArrayList of custom Objects by propertyCan someone show me a simple working implementation of PagerSlidingTabStrip?why spill failure happens for Custom Data Type in HadoopsetText on button from another activity androidKeycloak required action check in authentiation flowIs KeyCloak authentication using Custom User Attribute possible?Why onBindViewHolder index isn't incrementing in Recycler View?keycloak to keycloak data sync













1















I am trying to implement custom form action for user registration. I have added few custom fields on the form and I wish to validate those fields. After going through the keycloak documentation, I realised that I need to



  • Extend FormAction, FormActionFactory

  • Package the actionfactory in META-INF/services/org.keycloak.authentication.FormActionFactory

  • Deploy the JAR in keycloak/standalone/deployments folder.

I have done all the steps and verified that the provider is getting loaded. Here is the log from keycloak log file



15:35:29,962 WARN [org.keycloak.services] (ServerService Thread Pool -- 46) KC-SERVICES0047: organization-field-validation-action (com.phoenix.keycloak.forms.action.OrganizationFormAction) is implementing the internal SPI form-action. This SPI is internal and may change without notice


But when I go to Authentication execution screen, the provider is not listed.
enter image description here



Here is the code for custom action.



/**
*
*/
package com.phoenix.keycloak.forms.action;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.core.MultivaluedMap;

import org.keycloak.Config.Scope;
import org.keycloak.authentication.FormAction;
import org.keycloak.authentication.FormActionFactory;
import org.keycloak.authentication.FormContext;
import org.keycloak.authentication.ValidationContext;
import org.keycloak.events.Details;
import org.keycloak.events.Errors;
import org.keycloak.forms.login.LoginFormsProvider;
import org.keycloak.models.AuthenticationExecutionModel.Requirement;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.FormMessage;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.services.validation.Validation;

/**
* @author Yogesh Jadhav
*
*/
public class OrganizationFormAction implements FormAction, FormActionFactory

private static final String PROVIDER_ID = "organization-field-validation-action";

private static Requirement[] REQUIREMENT_CHOICES = Requirement.REQUIRED, Requirement.DISABLED ;

/*
* (non-Javadoc)
*
* @see org.keycloak.provider.Provider#close()
*/
@Override
public void close()


/*
* (non-Javadoc)
*
* @see org.keycloak.provider.ProviderFactory#create(org.keycloak.models.
* KeycloakSession)
*/
@Override
public FormAction create(KeycloakSession arg0)
return this;


/*
* (non-Javadoc)
*
* @see org.keycloak.provider.ProviderFactory#getId()
*/
@Override
public String getId()
return PROVIDER_ID;


/*
* (non-Javadoc)
*
* @see org.keycloak.provider.ProviderFactory#init(org.keycloak.Config.Scope)
*/
@Override
public void init(Scope arg0)


/*
* (non-Javadoc)
*
* @see org.keycloak.provider.ProviderFactory#postInit(org.keycloak.models.
* KeycloakSessionFactory)
*/
@Override
public void postInit(KeycloakSessionFactory arg0)


/*
* (non-Javadoc)
*
* @see
* org.keycloak.authentication.ConfigurableAuthenticatorFactory#getDisplayType()
*/
@Override
public String getDisplayType()
return "Organization Profile Validation";


/*
* (non-Javadoc)
*
* @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
* getReferenceCategory()
*/
@Override
public String getReferenceCategory()
return null;


/*
* (non-Javadoc)
*
* @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
* getRequirementChoices()
*/
@Override
public Requirement[] getRequirementChoices()
return REQUIREMENT_CHOICES;


/*
* (non-Javadoc)
*
* @see
* org.keycloak.authentication.ConfigurableAuthenticatorFactory#isConfigurable()
*/
@Override
public boolean isConfigurable()
return true;


/*
* (non-Javadoc)
*
* @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
* isUserSetupAllowed()
*/
@Override
public boolean isUserSetupAllowed()
return true;


/*
* (non-Javadoc)
*
* @see org.keycloak.provider.ConfiguredProvider#getConfigProperties()
*/
@Override
public List<ProviderConfigProperty> getConfigProperties()
return null;


/*
* (non-Javadoc)
*
* @see org.keycloak.provider.ConfiguredProvider#getHelpText()
*/
@Override
public String getHelpText()
return "Validates organization name and mobile number field.";


/*
* (non-Javadoc)
*
* @see
* org.keycloak.authentication.FormAction#buildPage(org.keycloak.authentication.
* FormContext, org.keycloak.forms.login.LoginFormsProvider)
*/
@Override
public void buildPage(FormContext arg0, LoginFormsProvider arg1)


/*
* (non-Javadoc)
*
* @see
* org.keycloak.authentication.FormAction#configuredFor(org.keycloak.models.
* KeycloakSession, org.keycloak.models.RealmModel,
* org.keycloak.models.UserModel)
*/
@Override
public boolean configuredFor(KeycloakSession arg0, RealmModel arg1, UserModel arg2)
return false;


/*
* (non-Javadoc)
*
* @see org.keycloak.authentication.FormAction#requiresUser()
*/
@Override
public boolean requiresUser()
return false;


/*
* (non-Javadoc)
*
* @see
* org.keycloak.authentication.FormAction#setRequiredActions(org.keycloak.models
* .KeycloakSession, org.keycloak.models.RealmModel,
* org.keycloak.models.UserModel)
*/
@Override
public void setRequiredActions(KeycloakSession arg0, RealmModel arg1, UserModel arg2)


/*
* (non-Javadoc)
*
* @see
* org.keycloak.authentication.FormAction#success(org.keycloak.authentication.
* FormContext)
*/
@Override
public void success(FormContext arg0)


/*
* (non-Javadoc)
*
* @see
* org.keycloak.authentication.FormAction#validate(org.keycloak.authentication.
* ValidationContext)
*/
@Override
public void validate(ValidationContext context)
MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
List<FormMessage> errors = new ArrayList<>();

context.getEvent().detail(Details.REGISTER_METHOD, "form");
String eventError = Errors.INVALID_REGISTRATION;

if (Validation.isBlank(formData.getFirst("user.attributes.companyName")))
errors.add(new FormMessage("user.attributes.companyName", "missingOrganizationNameMessage"));


if (Validation.isBlank(formData.getFirst("user.attributes.contactPersonMobile")))
errors.add(new FormMessage("user.attributes.contactPersonMobile", "missingContactPersonMobileMessage"));


if (errors.size() > 0)
context.error(eventError);
context.validationError(formData, errors);
return;

else
context.success();






Not able to figure out what went wrong here.










share|improve this question


























    1















    I am trying to implement custom form action for user registration. I have added few custom fields on the form and I wish to validate those fields. After going through the keycloak documentation, I realised that I need to



    • Extend FormAction, FormActionFactory

    • Package the actionfactory in META-INF/services/org.keycloak.authentication.FormActionFactory

    • Deploy the JAR in keycloak/standalone/deployments folder.

    I have done all the steps and verified that the provider is getting loaded. Here is the log from keycloak log file



    15:35:29,962 WARN [org.keycloak.services] (ServerService Thread Pool -- 46) KC-SERVICES0047: organization-field-validation-action (com.phoenix.keycloak.forms.action.OrganizationFormAction) is implementing the internal SPI form-action. This SPI is internal and may change without notice


    But when I go to Authentication execution screen, the provider is not listed.
    enter image description here



    Here is the code for custom action.



    /**
    *
    */
    package com.phoenix.keycloak.forms.action;

    import java.util.ArrayList;
    import java.util.List;

    import javax.ws.rs.core.MultivaluedMap;

    import org.keycloak.Config.Scope;
    import org.keycloak.authentication.FormAction;
    import org.keycloak.authentication.FormActionFactory;
    import org.keycloak.authentication.FormContext;
    import org.keycloak.authentication.ValidationContext;
    import org.keycloak.events.Details;
    import org.keycloak.events.Errors;
    import org.keycloak.forms.login.LoginFormsProvider;
    import org.keycloak.models.AuthenticationExecutionModel.Requirement;
    import org.keycloak.models.KeycloakSession;
    import org.keycloak.models.KeycloakSessionFactory;
    import org.keycloak.models.RealmModel;
    import org.keycloak.models.UserModel;
    import org.keycloak.models.utils.FormMessage;
    import org.keycloak.provider.ProviderConfigProperty;
    import org.keycloak.services.validation.Validation;

    /**
    * @author Yogesh Jadhav
    *
    */
    public class OrganizationFormAction implements FormAction, FormActionFactory

    private static final String PROVIDER_ID = "organization-field-validation-action";

    private static Requirement[] REQUIREMENT_CHOICES = Requirement.REQUIRED, Requirement.DISABLED ;

    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.provider.Provider#close()
    */
    @Override
    public void close()


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.provider.ProviderFactory#create(org.keycloak.models.
    * KeycloakSession)
    */
    @Override
    public FormAction create(KeycloakSession arg0)
    return this;


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.provider.ProviderFactory#getId()
    */
    @Override
    public String getId()
    return PROVIDER_ID;


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.provider.ProviderFactory#init(org.keycloak.Config.Scope)
    */
    @Override
    public void init(Scope arg0)


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.provider.ProviderFactory#postInit(org.keycloak.models.
    * KeycloakSessionFactory)
    */
    @Override
    public void postInit(KeycloakSessionFactory arg0)


    /*
    * (non-Javadoc)
    *
    * @see
    * org.keycloak.authentication.ConfigurableAuthenticatorFactory#getDisplayType()
    */
    @Override
    public String getDisplayType()
    return "Organization Profile Validation";


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
    * getReferenceCategory()
    */
    @Override
    public String getReferenceCategory()
    return null;


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
    * getRequirementChoices()
    */
    @Override
    public Requirement[] getRequirementChoices()
    return REQUIREMENT_CHOICES;


    /*
    * (non-Javadoc)
    *
    * @see
    * org.keycloak.authentication.ConfigurableAuthenticatorFactory#isConfigurable()
    */
    @Override
    public boolean isConfigurable()
    return true;


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
    * isUserSetupAllowed()
    */
    @Override
    public boolean isUserSetupAllowed()
    return true;


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.provider.ConfiguredProvider#getConfigProperties()
    */
    @Override
    public List<ProviderConfigProperty> getConfigProperties()
    return null;


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.provider.ConfiguredProvider#getHelpText()
    */
    @Override
    public String getHelpText()
    return "Validates organization name and mobile number field.";


    /*
    * (non-Javadoc)
    *
    * @see
    * org.keycloak.authentication.FormAction#buildPage(org.keycloak.authentication.
    * FormContext, org.keycloak.forms.login.LoginFormsProvider)
    */
    @Override
    public void buildPage(FormContext arg0, LoginFormsProvider arg1)


    /*
    * (non-Javadoc)
    *
    * @see
    * org.keycloak.authentication.FormAction#configuredFor(org.keycloak.models.
    * KeycloakSession, org.keycloak.models.RealmModel,
    * org.keycloak.models.UserModel)
    */
    @Override
    public boolean configuredFor(KeycloakSession arg0, RealmModel arg1, UserModel arg2)
    return false;


    /*
    * (non-Javadoc)
    *
    * @see org.keycloak.authentication.FormAction#requiresUser()
    */
    @Override
    public boolean requiresUser()
    return false;


    /*
    * (non-Javadoc)
    *
    * @see
    * org.keycloak.authentication.FormAction#setRequiredActions(org.keycloak.models
    * .KeycloakSession, org.keycloak.models.RealmModel,
    * org.keycloak.models.UserModel)
    */
    @Override
    public void setRequiredActions(KeycloakSession arg0, RealmModel arg1, UserModel arg2)


    /*
    * (non-Javadoc)
    *
    * @see
    * org.keycloak.authentication.FormAction#success(org.keycloak.authentication.
    * FormContext)
    */
    @Override
    public void success(FormContext arg0)


    /*
    * (non-Javadoc)
    *
    * @see
    * org.keycloak.authentication.FormAction#validate(org.keycloak.authentication.
    * ValidationContext)
    */
    @Override
    public void validate(ValidationContext context)
    MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
    List<FormMessage> errors = new ArrayList<>();

    context.getEvent().detail(Details.REGISTER_METHOD, "form");
    String eventError = Errors.INVALID_REGISTRATION;

    if (Validation.isBlank(formData.getFirst("user.attributes.companyName")))
    errors.add(new FormMessage("user.attributes.companyName", "missingOrganizationNameMessage"));


    if (Validation.isBlank(formData.getFirst("user.attributes.contactPersonMobile")))
    errors.add(new FormMessage("user.attributes.contactPersonMobile", "missingContactPersonMobileMessage"));


    if (errors.size() > 0)
    context.error(eventError);
    context.validationError(formData, errors);
    return;

    else
    context.success();






    Not able to figure out what went wrong here.










    share|improve this question
























      1












      1








      1








      I am trying to implement custom form action for user registration. I have added few custom fields on the form and I wish to validate those fields. After going through the keycloak documentation, I realised that I need to



      • Extend FormAction, FormActionFactory

      • Package the actionfactory in META-INF/services/org.keycloak.authentication.FormActionFactory

      • Deploy the JAR in keycloak/standalone/deployments folder.

      I have done all the steps and verified that the provider is getting loaded. Here is the log from keycloak log file



      15:35:29,962 WARN [org.keycloak.services] (ServerService Thread Pool -- 46) KC-SERVICES0047: organization-field-validation-action (com.phoenix.keycloak.forms.action.OrganizationFormAction) is implementing the internal SPI form-action. This SPI is internal and may change without notice


      But when I go to Authentication execution screen, the provider is not listed.
      enter image description here



      Here is the code for custom action.



      /**
      *
      */
      package com.phoenix.keycloak.forms.action;

      import java.util.ArrayList;
      import java.util.List;

      import javax.ws.rs.core.MultivaluedMap;

      import org.keycloak.Config.Scope;
      import org.keycloak.authentication.FormAction;
      import org.keycloak.authentication.FormActionFactory;
      import org.keycloak.authentication.FormContext;
      import org.keycloak.authentication.ValidationContext;
      import org.keycloak.events.Details;
      import org.keycloak.events.Errors;
      import org.keycloak.forms.login.LoginFormsProvider;
      import org.keycloak.models.AuthenticationExecutionModel.Requirement;
      import org.keycloak.models.KeycloakSession;
      import org.keycloak.models.KeycloakSessionFactory;
      import org.keycloak.models.RealmModel;
      import org.keycloak.models.UserModel;
      import org.keycloak.models.utils.FormMessage;
      import org.keycloak.provider.ProviderConfigProperty;
      import org.keycloak.services.validation.Validation;

      /**
      * @author Yogesh Jadhav
      *
      */
      public class OrganizationFormAction implements FormAction, FormActionFactory

      private static final String PROVIDER_ID = "organization-field-validation-action";

      private static Requirement[] REQUIREMENT_CHOICES = Requirement.REQUIRED, Requirement.DISABLED ;

      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.Provider#close()
      */
      @Override
      public void close()


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ProviderFactory#create(org.keycloak.models.
      * KeycloakSession)
      */
      @Override
      public FormAction create(KeycloakSession arg0)
      return this;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ProviderFactory#getId()
      */
      @Override
      public String getId()
      return PROVIDER_ID;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ProviderFactory#init(org.keycloak.Config.Scope)
      */
      @Override
      public void init(Scope arg0)


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ProviderFactory#postInit(org.keycloak.models.
      * KeycloakSessionFactory)
      */
      @Override
      public void postInit(KeycloakSessionFactory arg0)


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.ConfigurableAuthenticatorFactory#getDisplayType()
      */
      @Override
      public String getDisplayType()
      return "Organization Profile Validation";


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
      * getReferenceCategory()
      */
      @Override
      public String getReferenceCategory()
      return null;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
      * getRequirementChoices()
      */
      @Override
      public Requirement[] getRequirementChoices()
      return REQUIREMENT_CHOICES;


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.ConfigurableAuthenticatorFactory#isConfigurable()
      */
      @Override
      public boolean isConfigurable()
      return true;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
      * isUserSetupAllowed()
      */
      @Override
      public boolean isUserSetupAllowed()
      return true;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ConfiguredProvider#getConfigProperties()
      */
      @Override
      public List<ProviderConfigProperty> getConfigProperties()
      return null;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ConfiguredProvider#getHelpText()
      */
      @Override
      public String getHelpText()
      return "Validates organization name and mobile number field.";


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#buildPage(org.keycloak.authentication.
      * FormContext, org.keycloak.forms.login.LoginFormsProvider)
      */
      @Override
      public void buildPage(FormContext arg0, LoginFormsProvider arg1)


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#configuredFor(org.keycloak.models.
      * KeycloakSession, org.keycloak.models.RealmModel,
      * org.keycloak.models.UserModel)
      */
      @Override
      public boolean configuredFor(KeycloakSession arg0, RealmModel arg1, UserModel arg2)
      return false;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.authentication.FormAction#requiresUser()
      */
      @Override
      public boolean requiresUser()
      return false;


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#setRequiredActions(org.keycloak.models
      * .KeycloakSession, org.keycloak.models.RealmModel,
      * org.keycloak.models.UserModel)
      */
      @Override
      public void setRequiredActions(KeycloakSession arg0, RealmModel arg1, UserModel arg2)


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#success(org.keycloak.authentication.
      * FormContext)
      */
      @Override
      public void success(FormContext arg0)


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#validate(org.keycloak.authentication.
      * ValidationContext)
      */
      @Override
      public void validate(ValidationContext context)
      MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
      List<FormMessage> errors = new ArrayList<>();

      context.getEvent().detail(Details.REGISTER_METHOD, "form");
      String eventError = Errors.INVALID_REGISTRATION;

      if (Validation.isBlank(formData.getFirst("user.attributes.companyName")))
      errors.add(new FormMessage("user.attributes.companyName", "missingOrganizationNameMessage"));


      if (Validation.isBlank(formData.getFirst("user.attributes.contactPersonMobile")))
      errors.add(new FormMessage("user.attributes.contactPersonMobile", "missingContactPersonMobileMessage"));


      if (errors.size() > 0)
      context.error(eventError);
      context.validationError(formData, errors);
      return;

      else
      context.success();






      Not able to figure out what went wrong here.










      share|improve this question














      I am trying to implement custom form action for user registration. I have added few custom fields on the form and I wish to validate those fields. After going through the keycloak documentation, I realised that I need to



      • Extend FormAction, FormActionFactory

      • Package the actionfactory in META-INF/services/org.keycloak.authentication.FormActionFactory

      • Deploy the JAR in keycloak/standalone/deployments folder.

      I have done all the steps and verified that the provider is getting loaded. Here is the log from keycloak log file



      15:35:29,962 WARN [org.keycloak.services] (ServerService Thread Pool -- 46) KC-SERVICES0047: organization-field-validation-action (com.phoenix.keycloak.forms.action.OrganizationFormAction) is implementing the internal SPI form-action. This SPI is internal and may change without notice


      But when I go to Authentication execution screen, the provider is not listed.
      enter image description here



      Here is the code for custom action.



      /**
      *
      */
      package com.phoenix.keycloak.forms.action;

      import java.util.ArrayList;
      import java.util.List;

      import javax.ws.rs.core.MultivaluedMap;

      import org.keycloak.Config.Scope;
      import org.keycloak.authentication.FormAction;
      import org.keycloak.authentication.FormActionFactory;
      import org.keycloak.authentication.FormContext;
      import org.keycloak.authentication.ValidationContext;
      import org.keycloak.events.Details;
      import org.keycloak.events.Errors;
      import org.keycloak.forms.login.LoginFormsProvider;
      import org.keycloak.models.AuthenticationExecutionModel.Requirement;
      import org.keycloak.models.KeycloakSession;
      import org.keycloak.models.KeycloakSessionFactory;
      import org.keycloak.models.RealmModel;
      import org.keycloak.models.UserModel;
      import org.keycloak.models.utils.FormMessage;
      import org.keycloak.provider.ProviderConfigProperty;
      import org.keycloak.services.validation.Validation;

      /**
      * @author Yogesh Jadhav
      *
      */
      public class OrganizationFormAction implements FormAction, FormActionFactory

      private static final String PROVIDER_ID = "organization-field-validation-action";

      private static Requirement[] REQUIREMENT_CHOICES = Requirement.REQUIRED, Requirement.DISABLED ;

      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.Provider#close()
      */
      @Override
      public void close()


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ProviderFactory#create(org.keycloak.models.
      * KeycloakSession)
      */
      @Override
      public FormAction create(KeycloakSession arg0)
      return this;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ProviderFactory#getId()
      */
      @Override
      public String getId()
      return PROVIDER_ID;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ProviderFactory#init(org.keycloak.Config.Scope)
      */
      @Override
      public void init(Scope arg0)


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ProviderFactory#postInit(org.keycloak.models.
      * KeycloakSessionFactory)
      */
      @Override
      public void postInit(KeycloakSessionFactory arg0)


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.ConfigurableAuthenticatorFactory#getDisplayType()
      */
      @Override
      public String getDisplayType()
      return "Organization Profile Validation";


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
      * getReferenceCategory()
      */
      @Override
      public String getReferenceCategory()
      return null;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
      * getRequirementChoices()
      */
      @Override
      public Requirement[] getRequirementChoices()
      return REQUIREMENT_CHOICES;


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.ConfigurableAuthenticatorFactory#isConfigurable()
      */
      @Override
      public boolean isConfigurable()
      return true;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.authentication.ConfigurableAuthenticatorFactory#
      * isUserSetupAllowed()
      */
      @Override
      public boolean isUserSetupAllowed()
      return true;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ConfiguredProvider#getConfigProperties()
      */
      @Override
      public List<ProviderConfigProperty> getConfigProperties()
      return null;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.provider.ConfiguredProvider#getHelpText()
      */
      @Override
      public String getHelpText()
      return "Validates organization name and mobile number field.";


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#buildPage(org.keycloak.authentication.
      * FormContext, org.keycloak.forms.login.LoginFormsProvider)
      */
      @Override
      public void buildPage(FormContext arg0, LoginFormsProvider arg1)


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#configuredFor(org.keycloak.models.
      * KeycloakSession, org.keycloak.models.RealmModel,
      * org.keycloak.models.UserModel)
      */
      @Override
      public boolean configuredFor(KeycloakSession arg0, RealmModel arg1, UserModel arg2)
      return false;


      /*
      * (non-Javadoc)
      *
      * @see org.keycloak.authentication.FormAction#requiresUser()
      */
      @Override
      public boolean requiresUser()
      return false;


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#setRequiredActions(org.keycloak.models
      * .KeycloakSession, org.keycloak.models.RealmModel,
      * org.keycloak.models.UserModel)
      */
      @Override
      public void setRequiredActions(KeycloakSession arg0, RealmModel arg1, UserModel arg2)


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#success(org.keycloak.authentication.
      * FormContext)
      */
      @Override
      public void success(FormContext arg0)


      /*
      * (non-Javadoc)
      *
      * @see
      * org.keycloak.authentication.FormAction#validate(org.keycloak.authentication.
      * ValidationContext)
      */
      @Override
      public void validate(ValidationContext context)
      MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
      List<FormMessage> errors = new ArrayList<>();

      context.getEvent().detail(Details.REGISTER_METHOD, "form");
      String eventError = Errors.INVALID_REGISTRATION;

      if (Validation.isBlank(formData.getFirst("user.attributes.companyName")))
      errors.add(new FormMessage("user.attributes.companyName", "missingOrganizationNameMessage"));


      if (Validation.isBlank(formData.getFirst("user.attributes.contactPersonMobile")))
      errors.add(new FormMessage("user.attributes.contactPersonMobile", "missingContactPersonMobileMessage"));


      if (errors.size() > 0)
      context.error(eventError);
      context.validationError(formData, errors);
      return;

      else
      context.success();






      Not able to figure out what went wrong here.







      java keycloak keycloak-services






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 21 at 15:56









      CuriousMindCuriousMind

      2,23322135




      2,23322135






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Apologies. I was looking at the wrong "Add Execution" option. I realized that each form also has a corresponding "Actions" menu. This menu also has "Add Execution" option.



          enter image description here



          After selecting that option, I could see my Custom Form action is displayed in the restricted list of actions.



          enter image description here






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55284482%2fkeycloak-custom-form-action-not-visible-in-flow%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Apologies. I was looking at the wrong "Add Execution" option. I realized that each form also has a corresponding "Actions" menu. This menu also has "Add Execution" option.



            enter image description here



            After selecting that option, I could see my Custom Form action is displayed in the restricted list of actions.



            enter image description here






            share|improve this answer



























              0














              Apologies. I was looking at the wrong "Add Execution" option. I realized that each form also has a corresponding "Actions" menu. This menu also has "Add Execution" option.



              enter image description here



              After selecting that option, I could see my Custom Form action is displayed in the restricted list of actions.



              enter image description here






              share|improve this answer

























                0












                0








                0







                Apologies. I was looking at the wrong "Add Execution" option. I realized that each form also has a corresponding "Actions" menu. This menu also has "Add Execution" option.



                enter image description here



                After selecting that option, I could see my Custom Form action is displayed in the restricted list of actions.



                enter image description here






                share|improve this answer













                Apologies. I was looking at the wrong "Add Execution" option. I realized that each form also has a corresponding "Actions" menu. This menu also has "Add Execution" option.



                enter image description here



                After selecting that option, I could see my Custom Form action is displayed in the restricted list of actions.



                enter image description here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 22 at 10:31









                CuriousMindCuriousMind

                2,23322135




                2,23322135





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid …


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55284482%2fkeycloak-custom-form-action-not-visible-in-flow%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

                    Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?