I have imageURL like https://resource.digitaldealer.com.au/image/3281718625d81ce1e136a0008808648_0_0.jpg, my main aim is to push image into Salesforce. For that, i'm trying to get Base64 from this url. once i get this base64 then i'll try to upload base64 content to Salesforce by using File concept of SFDC.
I have stuck while retrieve base64 from imageURL. Can anyone please help me?
FYI, Code
<iterate continueParent="true" description="urlIterator" expression="//url" id="listUnread" sequential="true">
<target>
<sequence>
<property description="fileURL" expression="//*[local-name()='url']" name="fileURL" scope="default" type="STRING"/>
<property description="uri.var.url" expression="get-property('fileURL')" name="uri.var.url" scope="default" type="STRING"/>
<log separator="===Input Image URL===">
<property expression="get-property('fileURL')" name="uri.var.url"/>
</log>
<call>
<endpoint>
<http method="get" uri-template="{uri.var.url}"/>
</endpoint>
</call>
<log level="full"/>
</sequence>
</target>
</iterate>
Exception:
[2019-12-09 12:26:14,762] [] ERROR - Axis2Sender Unexpected error during sending message out
org.apache.axis2.AxisFault: The system cannot infer the transport information from the %3Curl/%3E URL.
at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:86)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:116)
Please refer to this blog which explains How to use Enrich Mediator to download an image from a URL and use Synapse functions to base64 encode same using WSO2 ESB.
Related
I'm getting the below error when using BCryptPasswordEncoder in CAS 4.2 (Central Authentication Service).:
java.lang.IllegalStateException: Cannot convert value of type [org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder] to required type [org.jasig.cas.authentication.handler.PasswordEncoder] for property 'passwordEncoder': no matching editors or conversion strategy found
I've added all the dependencies in Maven. I also checked over CAS documents, but there is no proper information about how to configure BCryptPasswordEncoder with CAS.
deployerconfigcontext.xml (Maven for compilation):
<bean id="primaryAuthenticationHandler"
class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler"
p:dataSource-ref="dataSource"
p:passwordEncoder-ref="passwordEncoder"
p:sql="select PASSWORD from SD_AD_DAT_LOGIN where ACCESS_NAME=?" />
<bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
I've connected CAS with the Oracle database, and it validated the plain text password correctly. Now I want to use bcrypt password encoding, and store the encode password in the database so that CAS should validate the encode password.
Help me understand the usage of BCryptPasswordEncoder with CAS.
After some more analysis i got to know that CAS 4.2.7 doesn't support Bcrypt encoding so to use this we need to write new custom class (BCryptSearchModeSearchDatabaseAuthenticationHandler) to handle bcrypt encoding.
deployerconfig.xml :
<bean id="primaryAuthenticationHandler"
class="io.wicket.cas.BCryptSearchModeSearchDatabaseAuthenticationHandler"
p:dataSource-ref="dataSource"
p:tableUsers="SD_AD_DAT_LOGIN"
p:fieldUser="ACCESS_NAME"
p:fieldPassword="PASSWORD"
p:passwordEncoder-ref="passwordEncoder"/>
<bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:#172.16.0.72:1521:xe" />
<property name="username" value="PROD17102018" />
<property name="password" value="PROD17102018" />
</bean>
I've created a proxy to tweet using WSO2 ESB Twitter connector. My Tweet proxy looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="Tweet" startOnLoad="true" trace="disable"
transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property expression="json-eval($.message)" name="Tweet"
scope="default" type="STRING"/>
<twitter.init>
<consumerKey>xxxxxxxxxx</consumerKey>
<consumerSecret>xxxxxxxxxxxx</consumerSecret>
<accessToken>xxxxxxxxxxxxx</accessToken>
<accessTokenSecret>xxxxxxxxxx</accessTokenSecret>
</twitter.init>
<twitter.updateStatus>
<status>{$ctx:Tweet}</status>
</twitter.updateStatus>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>
The project was deployed without any errors but when ever i make a POST request to Tweet from Postman im getting an error status of 170 with a message Missing required parameter: status.
The Post request consist of a json like this.
{"Content-Type":"application/json","payload":"{\"message\":\"Hellow WSO2 ESB!!!! #WSO2 #Test\"}"}
In the ESB sever console it gives an error like this
ERROR - SynapseJsonPath #stringValueOf. Error evaluating JSON Path <$.message>. Returning empty result. Error>>> invalid path
Any particular reason why im getting this error?. How to overcome this?.
Change the property expression like this.
expression="json-eval($.payload.message)"
I used shiro annotations for example: #RequiresPermissions("module:books:list"). It is working fine with the permitted page.But if I try to access not permitted page it gives AuthorizationException. Can anyone tell me how to redirect to unauthorized page if AuthorizationException is caused?
Error 500: Internal Server Error
URI
/BookForAsia/authors/create
Class
org.apache.shiro.authz.AuthorizationException
Message
Not authorized to invoke method: public java.lang.Object org.ng.bookforasia.AuthorsController.create()
As I know there are two ways to achieve that.
1.define unauthorizedUrl in your shiro-Context.xml like this
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager" />
<property name="loginUrl" value="/views/login.html" />
<property name="successUrl" value="/views/main.html" />
<property name="unauthorizedUrl" value="/views/unauthorized.html" />
</bean>
2.define error-page in your web.xml
<error-page>
<exception-type>org.apache.shiro.authz.UnauthorizedException</exception-type>
<location>/views/unauthorized.html</location>
</error-page>
I'm trying to implement jpa idempotent repository just as described here http://camel.apache.org/file2.html, but i'm getting a Mbean export error.
On my application-context.xml i've the following section.
<bean id="mvStore" class="org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository" lazy-init="false">
<!-- Here we refer to the spring jpaTemplate -->
<constructor-arg index="0" ref="jpaTemplate" />
<!-- This 2nd parameter is the name (= a cateogry name). You can have different repositories with different names -->
<constructor-arg index="1" value="FileConsumer" />
</bean>
<context:mbean-server id="mbeanServer" />
<context:mbean-export server="mbeanServer" registration="replaceExisting" default-domain="br.com.touchtec"/>
If I remove the above section than the server (tomcat) starts just fine. Can anybody help me on this?
Here's the stack:
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository#6df960c4] with key 'mvStore'; nested exception is javax.management.MalformedObjectNameException: Key properties cannot be empty
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:602)
at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:527)
at org.springframework.jmx.export.MBeanExporter.afterPropertiesSet(MBeanExporter.java:413)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 50 more
Caused by: javax.management.MalformedObjectNameException: Key properties cannot be empty
at javax.management.ObjectName.construct(ObjectName.java:467)
at javax.management.ObjectName.<init>(ObjectName.java:1403)
at javax.management.ObjectName.getInstance(ObjectName.java:1285)
at org.springframework.jmx.support.ObjectNameManager.getInstance(ObjectNameManager.java:62)
at org.springframework.jmx.export.naming.MetadataNamingStrategy.getObjectName(MetadataNamingStrategy.java:114)
at org.springframework.jmx.export.MBeanExporter.getObjectName(MBeanExporter.java:728)
at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:631)
at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:592)
... 54 more
First of all, I hope you're clear on the fact the jmx part is not necessary to make the Idempotent Repository work. Your error is a pure JMX/Spring error, not linked to Camel.
If you want to use an MBeanExporter, you should read the official documentation on Spring JMX to have a better understaking of this matter.
Your MBeanExporter definition might look like
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="bean:name=mvStore" value-ref="mvStore"/>
</map>
</property>
<property name="server" ref="mbeanServer"/>
</bean>
Currently i am implementing web services using Spring-ws . Here i am struck with xsd validation . For xsd validation i am using the following configruation
<bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="xsdSchema" ref="schema" />
<property name="validateRequest" value="true" />
<property name="validateResponse" value="true" />
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/ProductSchema.xsd" />
</bean>
Here i am passing the xsd file during bean initialization . Is there any way for me to send this(ProductSchema.xsd) xsd file dynamically. Because I will comes to know which xsd file needs to send based on the input payload.
Please help me. Thanks in advance
I don't know how many XSD's you have, but perhaps you can define imports in ProductSchema.xsd to include the others. That's at least how I've got it set up.
For example:
<import namespace="http://namespace" schemaLocation="data.xsd" />
I'm not quite sure of what you are trying to do.
But you can make different endpoints/methods that matches different payloads by annotating the handler method with a localPart that matches the name of an element i the payload:
#Endpoint
public class MyEndpoint {
#PayloadRoot(namespace = NAMESPACE_URI, localPart = "NameOfMyXmlRequestElement")
#ResponsePayload
public MyResponse handleMyRequest(#RequestPayload MyRequest MyRequest) throws Exception {
...
A recived request can then be unmarshalled/validated using a specific schema:
<bean id="myJaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>mydomain.model.oxm.MyRequest</value>
<value>mydomain.model.oxm.MyResponse</value>
</list>
</property>
<property name="schema" ref="MyServiceSchema" />
</bean>
<bean id="MyServiceSchema" class="org.springframework.core.io.ClassPathResource">
<constructor-arg value="WEB-INF/schemas/MyService.xsd" />
</bean>
The MyRequest class must be annotated to work with the Jaxb2marshaller, #XmlRootElement(name="MyRequest") etc...