I'm using HTTP request in Mule ESB and need to implement HTTP basic auth in it. Now I do this by using explicit authorization header:
<http:request config-ref="HTTP_Request_Configuration" path="/activiti-rest/service/runtime/process-instances" method="POST" doc:name="Request to BPM">
<http:request-builder>
<http:header headerName="Authorization" value="Basic a2VybWl0OnBhc3N3b3JkMQ=="/>
</http:request-builder>
</http:request>
Is there any direct way to enter user and password for basic auth in Mule http:request?
There sure is:
<http:request-config name="basicConfig" host="localhost" port="${httpPort}">
<http:basic-authentication username="#[user]" password="#[password]" preemptive="#[preemptive]" />
</http:request-config>
Related
I creating Rest Web service for fetching attachment file through http and storing file to local drive so i need filename dynamically as it is come in http request
My flow as follows
<foreach doc:name="For Each">
<set-payload value="#[payload.getInputStream() ]" doc:name="Get Inputstream from Payload"/>
<logger message="}}}#[message.inboundAttachments['payload']]" level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="F:\mule_data\e_files" responseTimeout="10000" doc:name="File" outputPattern="abcd.jpg"/>
</foreach>
<set-payload value="{"status":"success"}" doc:name="Generate JSON Response" />
</flow>
Here outputPattern="abcd.jpg" is harcoded so i need filename and format which coming through request
Please help
i refer from https://blogs.mulesoft.com/dev/mule-dev/soap-rest-attachments/
Please go through my answer in the question linked below.
How send a file in an HTTP request and upload it to file server via FTP in Mule
Once you are able to read/get the attachment file,you can get all the metadata associated with file.For reading name you can do following-
use #[payload.dataSource.part.fileName] to get name of attachment.
I configured the logout endpoint (URL) in the relying party trust as:
https:\abstractmachine.domain.local/adfs/ls/?wa=wsignout1.0
With POST binding
I also changed the default SingleLogoutService node value in the federation metadata from its default to the same link as the end point URL configured at ADFS. Without renaming it was giving error while sending the logout request.
Now, after configuration, the ADFS does say it logged out successfully and displays its logout page but users can still login without having to provide creadentials and it seems that the previous creadentails are still being cached.
Also, it is not redirecting to the response URL (I have set the response URL as:)
https:\abstractmachine.domain.local/webapp/logout.aspx
SAML logout not working in ADFS 2.0
I configured the logout endpoint (URL) in the relying party trust as:
https:\abstractmachine.domain.local/adfs/ls/?wa=wsignout1.0
With POST binding
I also changed the default SingleLogoutService node value in the federation metadata from its default to https//abstractmachine.domain.local/adfs/ls/?wa=wsignout1.0. Without renaming it was giving error while sending the logout request.
Now, after configuration, the ADFS does say it logged out successfully and displays its logout page but users can still login without having to provide credentials and it seems that the previous credentials are still being cached.
Am i missing some settings or is there any other method for logging out of ADFS with SAML request?
Also, it is not redirecting to the response URL after logout
The logout request that I am using is as below:
<?xml version="1.0" encoding="UTF-8"?> <samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_a8b394ff-a850-484d-91a1-2daeeeb35b52" Version="2.0" IssueInstant="2016-07-04T13:19:02.582Z" Destination="https://nsv-adfsbal.dristi.local/adfs_app/IdPLogOutResponse.aspx" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" NotOnOrAfter="2016-07-04T13:24:02.582Z"> <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://nsv-adfsbal.dristi.local/adfs/services/trust</Issuer> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<ds:Reference URI="#_a8b394ff-a850-484d-91a1-2daeeeb35b52">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<ds:DigestValue>knf74cRA51WBnpL3ZvPolhWHY90=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>c7VpbqOi0iRaRjfP8EUrS1GS0ne8MA4uW26GA62b5YwHlIHjC91fTfv4r/IuXONs7ny3J8c/If+jKK3dpttesmYmv1kq3p16o5IxlAEwoZ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HnB8ndDYPDE85XSYP4K2FDI/bzP2v2aowGHuZfyONvzgPF5NNtSl7ECo6DPEpSQ15DhTxfkC/YvJteiBhvY+2ij2+2fisl1i8GYzv/E8WnBvF4tJ9rI0EXC4GJ3Az2X+TgJF60Gqf+V2Jqc2KEqLqtG9nLQ1QU5uqS30lsz6m8LrSQkKvUi+RtSlg+rxA+D6hXGMwqfVQbR6yTrYLoyV5Z1zKmS0VXHXellq0Ltmejf6spg=</ds:X509Certificate>
</ds:X509Data>
</KeyInfo> </ds:Signature> <NameID xmlns="urn:oasis:names:tc:SAML:2.0:assertion">user.name#user.local</NameID> <samlp:SessionIndex>_7235ddb0-9fca-4545-9c57-aecdfa4b8eb2</samlp:SessionIndex> </samlp:LogoutRequest>
Using the deprecated http implementation it was possible to dynamically set the url on an outbound http endpoint from the payload or properties:
<http:outbound-endpoint address="http://#[payload]" method="GET" />
Is it possible to do this using the new http request connector?
Yes, it is. Here is a simple example:
<http:request-config
name="HTTP_Request_Configuration"
host="#[flowVars.address]"
port="80"
basePath="/"
doc:name="HTTP Request Configuration"/>
<flow name="httpFlow">
...
<set-variable
variableName="address"
value="#[message.inboundProperties.'http.query.params'.site]"
doc:name="Set site address variable"/>
<http:request
config-ref="HTTP_Request_Configuration"
path="/"
method="GET"
doc:name="Get dynamic HTTP"/>
</flow>
Just define the host attribute using the MEL expression you require.
host="#[flowVars.someVariable]"
I have a requirement in which i need to call a servlet from mule flow.I got one answer from the below site
http://mule.1045714.n5.nabble.com/Creating-query-string-for-calling-a-servlet-td2665836.html
But when i copy that code in my flow it is showing some errors in flow. Is there any other method or solution to call servlet from mule. I have servlet URL and username and password. I am using mule 3.5 anypoint studio. Please help me in completing this task
EDIT: (Pasted from a comment from the OP)
<flow name="CallServletServiceFlow1" doc:name="CallServletServiceFlow1">
<http:inbound-endpoint exchange-pattern="request-response" doc:name="HTTP" address="localhost:8080/servlet"/>
<object-to-string-transformer doc:name="Object to String"/>
<http:outbound-endpoint exchange-pattern="request-response" user="javauser" password="javauser1" method="GET" doc:name="HTTP" address="servlet/customTaskServlet?" connector-ref="HTTP_HTTPS"/>
</flow>
You seem to be copying old Mule 2 syntax in Mule 3, so this can not work.
Just use a simple HTTP outbound endpoint in your flow.
Reference: http://www.mulesoft.org/documentation/display/current/HTTP+Transport+Reference
EDIT: If you use the address attribute in HTTP endpoints (instead of the host port and path), you need to specify the scheme. So for example, you should replace address="localhost:8080/servlet" with address="http://localhost:8080/servlet".
I am trying to poll an RSS feed using Mule Studio but have been unsuccessful polling the information using the http outbound-endpoint in the Mule application. I have previously encountered the same issue using the http inbound-endpoint with the same site but was able to resolve the issue by assigning the User-Agent to MuleESB by setting the address to be
http://www.theaggie.org/feed/?User-Agent=MuleESB
However, now with the http outbound-endpoint, I am unable to poll the feed and get a 403 Forbidden error. My XML for the flow is
<flow name="aggregatorFlow1" doc:name="aggregatorFlow1">
<poll>
<processor-chain>
<set-variable variableName="httpMessages" value="#[[]]" />
<http:outbound-endpoint exchange-pattern="one-way" address="http://www.theaggie.org/feed/?User-Agent=MuleESB" method="GET" />
<expression-component>httpMessages.add(message.payloadAs(java.lang.String))</expression-component>
</processor-chain>
</poll>
<logger level="INFO" message="#[httpMessages]" />
</flow>
If I change the exchange-pattern to request-response, the logger would just output [ ]. I do not have issues with other sites using the same xml code.
Clearly the exchange-pattern should be request-response, as you seem to care about the payload of the response.
Try adding the following before the http:outbound-endpoint:
<set-property propertyName="User-Agent" value="MuleESB" />