net.loginbuddy.config/src/main/java/net/loginbuddy/config/HeadOfInitialize.java
/**
   * Register loginbuddy at the provider and remember a few details for later use
   */
Register loginbuddy at the provider and remember a few details for later use
Register loginbuddy at the provider and remember a few details for later use
private static Providers registerProvider(String issuer, String discoveryUrl, LoginbuddyContext sessionCtx)
      throws IOException {
    List<NameValuePair> formParameters = new ArrayList<>();
    formParameters.add(new BasicNameValuePair(Constants.ISSUER.getKey(), issuer));
    formParameters.add(new BasicNameValuePair(Constants.DISCOVERY_URL.getKey(), discoveryUrl));
    formParameters.add(new BasicNameValuePair(Constants.REDIRECT_URI.getKey(), DiscoveryUtil.UTIL.getRedirectUri()));
    MsgResponse msg = HttpHelper
        .postMessage(formParameters, "https://loginbuddy-oidcdr:445/oidcdr/register", "application/json");
    if (msg.getStatus() == 200) {
      Providers providers = LoginbuddyUtil.UTIL.getProviderConfigFromJsonString(msg.getMsg());
      sessionCtx.put(Constants.ISSUER_HANDLER.getKey(), Constants.ISSUER_HANDLER_OIDCDR.getKey());
      sessionCtx.put(Constants.PROVIDER_CLIENT_ID.getKey(), providers.getClientId()); 
      sessionCtx.put(Constants.PROVIDER_CLIENT_SECRET.getKey(), providers.getClientSecret()); 
      sessionCtx.put(Constants.PROVIDER_REDIRECT_URI.getKey(), providers.getRedirectUri()); 
      return providers;
    } else {
      LOGGER.warning(msg.getMsg());
      return null;
    }
  }
private static Providers registerProvider ( String issuer , String discoveryUrl , LoginbuddyContext sessionCtx ) throws IOException { List < NameValuePair > formParameters = new ArrayList < > ( ) ; formParameters . add ( new BasicNameValuePair ( Constants . ISSUER . getKey ( ) , issuer ) ) ; formParameters . add ( new BasicNameValuePair ( Constants . DISCOVERY_URL . getKey ( ) , discoveryUrl ) ) ; formParameters . add ( new BasicNameValuePair ( Constants . REDIRECT_URI . getKey ( ) , DiscoveryUtil . UTIL . getRedirectUri ( ) ) ) ; MsgResponse msg = HttpHelper . postMessage ( formParameters , "https://loginbuddy-oidcdr:445/oidcdr/register" , "application/json" ) ; if ( msg . getStatus ( ) == 200 ) { Providers providers = LoginbuddyUtil . UTIL . getProviderConfigFromJsonString ( msg . getMsg ( ) ) ; sessionCtx . put ( Constants . ISSUER_HANDLER . getKey ( ) , Constants . ISSUER_HANDLER_OIDCDR . getKey ( ) ) ; sessionCtx . put ( Constants . PROVIDER_CLIENT_ID . getKey ( ) , providers . getClientId ( ) ) ; sessionCtx . put ( Constants . PROVIDER_CLIENT_SECRET . getKey ( ) , providers . getClientSecret ( ) ) ; sessionCtx . put ( Constants . PROVIDER_REDIRECT_URI . getKey ( ) , providers . getRedirectUri ( ) ) ; return providers ; } else { LOGGER . warning ( msg . getMsg ( ) ) ; return null ; } }
Register loginbuddy at the provider and remember a few details for later use
Register loginbuddy at the provider and remember a few details for later use
// TODO take loginbuddys redirect_uri for dynamic registrations from a net.loginbuddy.service.config file // we have to store this in the session to make it available later // we have to store this in the session to make it available later // we have to store this in the session to make it available later