Search in sources :

Example 6 with SerializeException

use of com.nimbusds.oauth2.sdk.SerializeException in project microsoft-authentication-library-for-java by AzureAD.

the class ClientAuthenticationPost method applyTo.

@Override
public void applyTo(HTTPRequest httpRequest) throws SerializeException {
    if (httpRequest.getMethod() != HTTPRequest.Method.POST)
        throw new SerializeException("The HTTP request method must be POST");
    String ct = String.valueOf(httpRequest.getEntityContentType());
    if (ct == null)
        throw new SerializeException("Missing HTTP Content-Type header");
    if (!ct.equals(HTTPContentType.ApplicationURLEncoded.contentType))
        throw new SerializeException("The HTTP Content-Type header must be " + HTTPContentType.ApplicationURLEncoded.contentType);
    Map<String, List<String>> params = httpRequest.getQueryParameters();
    params.putAll(toParameters());
    String queryString = URLUtils.serializeParameters(params);
    httpRequest.setQuery(queryString);
}
Also used : SerializeException(com.nimbusds.oauth2.sdk.SerializeException) List(java.util.List)

Aggregations

HTTPResponse (com.nimbusds.oauth2.sdk.http.HTTPResponse)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Test (org.testng.annotations.Test)4 SerializeException (com.nimbusds.oauth2.sdk.SerializeException)2 URI (java.net.URI)2 URL (java.net.URL)2 List (java.util.List)2 TokenErrorResponse (com.nimbusds.oauth2.sdk.TokenErrorResponse)1 HashMap (java.util.HashMap)1