use of com.microsoft.identity.common.internal.commands.parameters.IHasExtraParameters in project microsoft-authentication-library-common-for-android by AzureAD.
the class BaseController method performTokenRequest.
protected TokenResult performTokenRequest(@SuppressWarnings(WarningType.rawtype_warning) @NonNull final OAuth2Strategy strategy, @SuppressWarnings(WarningType.rawtype_warning) @NonNull final AuthorizationRequest request, @NonNull final AuthorizationResponse response, @NonNull final InteractiveTokenCommandParameters parameters) throws IOException, ClientException {
final String methodName = ":performTokenRequest";
HttpWebRequest.throwIfNetworkNotAvailable(parameters.getAndroidApplicationContext(), parameters.isPowerOptCheckEnabled());
// Suppressing unchecked warnings due to casting of type AuthorizationRequest to GenericAuthorizationRequest and AuthorizationResponse to GenericAuthorizationResponse in arguments of method call to createTokenRequest
@SuppressWarnings(WarningType.unchecked_warning) final TokenRequest tokenRequest = strategy.createTokenRequest(request, response, parameters.getAuthenticationScheme());
if (tokenRequest instanceof MicrosoftTokenRequest) {
((MicrosoftTokenRequest) tokenRequest).setClientAppName(parameters.getApplicationName());
((MicrosoftTokenRequest) tokenRequest).setClientAppVersion(parameters.getApplicationVersion());
}
if (tokenRequest instanceof IHasExtraParameters && parameters instanceof IHasExtraParameters) {
((IHasExtraParameters) tokenRequest).setExtraParameters(((IHasExtraParameters) parameters).getExtraParameters());
}
logExposedFieldsOfObject(TAG + methodName, tokenRequest);
// Suppressing unchecked warnings due to casting of type TokenRequest to GenericTokenRequest in argument of method call to requestToken
@SuppressWarnings(WarningType.unchecked_warning) final TokenResult tokenResult = strategy.requestToken(tokenRequest);
logResult(TAG, tokenResult);
return tokenResult;
}
use of com.microsoft.identity.common.internal.commands.parameters.IHasExtraParameters in project microsoft-authentication-library-common-for-android by AzureAD.
the class ObjectMapper method constuctMapFromObject.
/**
* Method for converting the contents of an object into a map. Important to the implementation of
* this method is the behavior of GSON which excludes null fields from the resulting JSON. A
* TreeMap was chosen to simplify testing, and the resulting map is in key order.
*
* @param object the object to convert.
* @return a map representation of the object.
*/
public static Map<String, String> constuctMapFromObject(Object object) {
String json = ObjectMapper.serializeObjectToJsonString(object);
Type stringMap = new TypeToken<TreeMap<String, String>>() {
}.getType();
TreeMap<String, String> fields = new Gson().fromJson(json, stringMap);
if (object instanceof IHasExtraParameters) {
final IHasExtraParameters params = (IHasExtraParameters) object;
if (params.getExtraParameters() != null) {
for (final Map.Entry<String, String> e : params.getExtraParameters()) {
if (e.getKey() != null) {
fields.put(e.getKey(), e.getValue());
}
}
}
}
return fields;
}
Aggregations