private AdalOAuthAuthorizationGrant processPasswordGrant(
            AdalOAuthAuthorizationGrant authGrant) throws Exception {

        if (!(authGrant.getAuthorizationGrant() instanceof ResourceOwnerPasswordCredentialsGrant)) {
            return authGrant;
        }

        ResourceOwnerPasswordCredentialsGrant grant = (ResourceOwnerPasswordCredentialsGrant) authGrant
                .getAuthorizationGrant();

        UserDiscoveryResponse userDiscoveryResponse = UserDiscoveryRequest.execute(
                context.authenticationAuthority.getUserRealmEndpoint(grant.getUsername()),
                this.headers.getReadonlyHeaderMap(),
                context.proxy, 
                context.sslSocketFactory);
        if (userDiscoveryResponse.isAccountFederated()) {
            WSTrustResponse response = WSTrustRequest.execute(
                    userDiscoveryResponse.getFederationMetadataUrl(),
                    grant.getUsername(), grant.getPassword().getValue(), userDiscoveryResponse.getCloudAudienceUrn(),
                    context.proxy, context.sslSocketFactory, context.isLogPii());

            AuthorizationGrant updatedGrant = null;
            if (response.isTokenSaml2()) {
                updatedGrant = new SAML2BearerGrant(new Base64URL(
                        Base64.encodeBase64String(response.getToken().getBytes(
                                "UTF-8"))));
            }
            else {
                updatedGrant = new SAML11BearerGrant(new Base64URL(
                        Base64.encodeBase64String(response.getToken()
                                .getBytes())));
            }

            authGrant = new AdalOAuthAuthorizationGrant(updatedGrant,
                    authGrant.getCustomParameters());
        }

        return authGrant;
    }
private AdalOAuthAuthorizationGrant processPasswordGrant ( AdalOAuthAuthorizationGrant authGrant ) throws Exception { if ( ! ( authGrant . getAuthorizationGrant ( ) instanceof ResourceOwnerPasswordCredentialsGrant ) ) { return authGrant ; } ResourceOwnerPasswordCredentialsGrant grant = ( ResourceOwnerPasswordCredentialsGrant ) authGrant . getAuthorizationGrant ( ) ; UserDiscoveryResponse userDiscoveryResponse = UserDiscoveryRequest . execute ( context . authenticationAuthority . getUserRealmEndpoint ( grant . getUsername ( ) ) , this . headers . getReadonlyHeaderMap ( ) , context . proxy , context . sslSocketFactory ) ; if ( userDiscoveryResponse . isAccountFederated ( ) ) { WSTrustResponse response = WSTrustRequest . execute ( userDiscoveryResponse . getFederationMetadataUrl ( ) , grant . getUsername ( ) , grant . getPassword ( ) . getValue ( ) , userDiscoveryResponse . getCloudAudienceUrn ( ) , context . proxy , context . sslSocketFactory , context . isLogPii ( ) ) ; AuthorizationGrant updatedGrant = null ; if ( response . isTokenSaml2 ( ) ) { updatedGrant = new SAML2BearerGrant ( new Base64URL ( Base64 . encodeBase64String ( response . getToken ( ) . getBytes ( "UTF-8" ) ) ) ) ; } else { updatedGrant = new SAML11BearerGrant ( new Base64URL ( Base64 . encodeBase64String ( response . getToken ( ) . getBytes ( ) ) ) ) ; } authGrant = new AdalOAuthAuthorizationGrant ( updatedGrant , authGrant . getCustomParameters ( ) ) ; } return authGrant ; }
@param authGrant