/*
 * Copyright 2013-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.cloudfoundry.reactor.tokenprovider;

import org.cloudfoundry.reactor.TokenProvider;
import org.immutables.value.Value;
import reactor.core.publisher.Mono;
import reactor.ipc.netty.http.client.HttpClientRequest;

/**
 * The OAuth Password Grant implementation of {@link TokenProvider}
 */
@Value.Immutable
abstract class _PasswordGrantTokenProvider extends AbstractUaaTokenProvider {

    /**
     * The password
     */
    abstract String getPassword();

    /**
     * The username
     */
    abstract String getUsername();

    @Override
    Mono<Void> tokenRequestTransformer(Mono<HttpClientRequest> outbound) {
        return outbound
            .then(request -> request
                .sendForm(form -> form
                    .multipart(false)
                    .attr("client_id", getClientId())
                    .attr("client_secret", getClientSecret())
                    .attr("grant_type", "password")
                    .attr("password", getPassword())
                    .attr("username", getUsername()))
                .then());
    }

}

@@ -664,16 +664,50 @@
 vider;%0A%0A
+import org.cloudfoundry.Nullable;%0A
 import o
@@ -745,16 +745,16 @@
 ovider;%0A
-
 import o
@@ -1187,16 +1187,109 @@
 rname();
+%0A    %0A    /**%0A     * The login hint%0A     */%0A    @Nullable%0A    abstract String getLoginHint();
 %0A%0A    @O
@@ -1782,17 +1782,16 @@
 rname())
-)
 %0A       
@@ -1803,22 +1803,71 @@
     
-.then(
+%09.attr(%22login_hint%22, getLoginHint()
 ))
-;
 %0A    
+            .then());
 %7D%0A%0A%7D

Add login_hint for Password Grant Token