I'm trying to invoke ProfileFormHandler's create handle using ATG rest client as shown below.
mSession = RestSession.createSession(mHost, mPort,"kim#example.com","password");
mSession.setUseHttpsForLogin(false);
mSession.login();
Map<String,Object> params = new HashMap<String,Object>();
params.put("value.login", "buddha#oracle.com");
params.put("value.email", "buddha#oracle.com");
params.put("value.password", "password");
RestResult result = RestComponentHelper.executeMethod("/atg/userprofiling/ProfileFormHandler","create",null,params,mSession);
I'm getting form exceptions that says, I'm not passing Login and Password Fields.
["Missing value for the required property Password",
"Missing value for the required property Login name"]
I've tried all combinations of login and password fields like value.login, Login, login, value.Login etc., but nothing seemed to work. All combinations giving the same form exceptions.
How do I invoke an ATG form handler using ATG REST Client and pass parameters to it?
Definitely need more information but looking at your code I can see that you have a value.login which is not configured ootb and believe this is causing the NPE. Assuming you have not customized the ootb ATG RegistrationFormHandler and the required field in the repository the only values you need to pass to the form handler are:
value.email
value.password
value.confirmPassword
value.firstName
value.lastName
Also, the help is specific that the data-type of the value property needs to be java.util.Dictionary
Add the following to /atg/rest/security/restSecurityConfiguration.xml
<resource component="/atg/userprofiling/ProfileFormHandler" secure="false">
<method name="handleCreate" secure="false">
<acl value="EVERYONE:read,write,execute" />
</method>
<property name="value.login" secure="false" />
<property name="value.password" secure="false" />
</resource>
Related
I am trying to populate a property in a WSO2 proxy. I'am using the following syntax and xpath expression:
<property expression="//RelationValueList/PersonnelRelationValueUnitType[RelAttrId='R54' and DateTo=max(//RelationValueList/PersonnelRelationValueUnitType[RelAttrId='R54']/DateTo/xs:dateTime(.))][last()]/RelationValue" name="RelValue" scope="default" type="STRING"/>
This Xpath expression is working fine in an online Xpath tester. But when using it in WSO2 expression of a property mediator it gives me the following Eclipse error:
wso2 unknown synapse configuration tag
Error message
The XML document looks like this:
<GetPersonnelResponse>
<GetPersonnelResult>
<RelationValueList>
<PersonnelRelationValueUnitType>
<RelAttrId>C1</RelAttrId>
<RelationValue>1234</RelationValue>
<DateFrom>1900-01-02T00:00:00</DateFrom>
<DateTo>2199-12-31T00:00:00</DateTo>
</PersonnelRelationValueUnitType>
<PersonnelRelationValueUnitType>
<RelAttrId>R54</RelAttrId>
<RelationValue>GEN123</RelationValue>
<DateFrom>1900-01-02T00:00:00</DateFrom>
<DateTo>2017-12-04T00:00:00</DateTo>
</PersonnelRelationValueUnitType>
<PersonnelRelationValueUnitType>
<RelAttrId>R54</RelAttrId>
<RelationValue>GEN456</RelationValue>
<DateFrom>2017-12-05T00:00:00</DateFrom>
<DateTo>2099-12-31T00:00:00</DateTo>
</PersonnelRelationValueUnitType>
</RelationValueList>
</GetPersonnelResult>
</GetPersonnelResponse>
Xpath 2.0 is enabled in WSO2esb.
I need to select the RelationValue with the highest DateTo value. If there are multiple values, I take the last one.
Anyone knows how to fix this?
You use namespace xs: in your expression. You need to define it in top parent tag of it mediator.
I am trying to convert a request working as in below call to Spring Integration Async call
function sendToSomething(){
var formattedDate = $.datepicker.formatDate('yy-mm-dd', new Date());
var emailAddress = $("#prefferedemail").val();
// Call to Send email address to something
$.ajax(
{
global: false,
type : "POST",
url : "http://xyz.something.com/pub/rf?_ri_=X0Gzc2X"
+ "& EMAIL_PERMISSION_STATUS_=I&email_address_=" + emailAddress + "&SOURCE_CODE=CPK&EMAIL_PREF_CH_DT=" + formattedDate,
dataType : "jsonp",
}
);
}
}
Key point is its supposed to use http and jsonp
I am trying to configure something like below
<int:gateway id="asyncSomeIntService"
service-interface="com.staples.eoe.integration.AsyncSomeService" default-request-channel="someRequestChannel" />
<int-http:outbound-gateway url="http://xyz.something.com/pub/rf?_ri_=X0Gzc2X "&EMAIL_PERMISSION_STATUS_=I&email_address_={emailAddress}&SOURCE_CODE=CPK&EMAIL_PREF_CH_DT={formattedDate}"
http-method="POST" expected-response-type="java.lang.String" request-factory="requestFactory"
request-channel="someRequestChannel" reply-channel="someReplyChannel">
<int-http:uri-variable name="emailAddress" expression="headers.emailAddress" />
<int-http:uri-variable name="formattedDate" expression="headers.formattedDate" />
</int-http:outbound-gateway>
<bean id="requestFactory" class="org.springframework.http.client.SimpleClientHttpRequestFactory">
<property name="connectTimeout" value="5000" />
<property name="readTimeout" value="5000" />
</bean>
And the idea was to call from Server layer as below
Message<String> message = MessageBuilder
.withPayload("something")
.setHeader("formattedDate", "15-01-27")
.setHeader("emailAddress", customer.getPreferredEmail())
.build();
The Request submits the URL fine,
However I get part of response are as below
"It is likely that your input did not pass our validation process."
Is there a way to send JSONP request like in above ajax call using Spring Integration?
Good question though!
However if we go to the jQuery docs, we'll see this description for the dataType : "jsonp":
If jsonp is specified, $.ajax() will automatically append a query string parameter of (by default) callback=? to the URL. The jsonp and jsonpCallback properties of the settings passed to $.ajax() can be used to specify, respectively, the name of the query string parameter and the name of the JSONP callback function. The server should return valid JavaScript that passes the JSON response into the callback function. $.ajax() will execute the returned JavaScript, calling the JSONP callback function, before passing the JSON object contained in the response to the $.ajax() success handler.
So, since Spring Integration HTTP support isn't jQuery-based framework, we should go with standard JSONP rules and add that callback=? parameter to the url.
But... since we are in the Java I don't think that we will be able to execute a returned response as JavaScript. Although, do we need that since we can parse response body in the downstream using Java JSON abilities?
I'm acting as a service provider in a Shibboleth SSO interaction. I'm successfully getting back the SAML response with the expected attributes inside. However, these attributes are not showing up in the /Shibboleth.sso/Session Attributes list.
I have the <MetadataProvider> tag in the shibboleth.xml file. I'm wondering what else I could be doing wrong?
In the shibd.log I see the following:
skipping unmapped SAML 2.0 Attribute with Name: xxxx, Format:urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified
skipping unmapped SAML 2.0 Attribute with Name: yyyy
EDIT - I also added to attribute-map.xml:
<Attribute Name="xxxx" id="xxxx" />
<Attribute Name="yyyy" id="yyyy" />
The attributes do not have fully qualified names in the IdP's metadata.xml. The names are just "xxxx" and "yyyy". Does this matter?
Finally, in the IdP's metadata.xml, they have this:
<saml:Attribute Name="xxxx" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"/>
<saml:Attribute Name="yyyy" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"/>
From Shibboleth documentation:
The SAML V2.0 LDAP/X.500 Attribute Profile specifies that X.500/LDAP
attributes be named by utilizing the urn:oid namespace. These names
are simply constructed using the string urn:oid followed by the OID
defined for the attribute.
So definitely you need to use OID for attribute names, attribute-map.xml has lots of examples.
For custom attributes that are specific to some IdP they will have to supply you with OIDs to use.
I believe I have solved it. In the attribute-map.xml I had to add:
<Attribute name="xxxx" id="xxxx">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true"/>
</Attribute>
<Attribute name="yyyy" id="yyyy">
<AttributeDecoder xsi:type="NameIDAttributeDecoder" formatter="$Name" defaultQualifiers="true"/>
</Attribute>
See here: NativeSPAttributeDecoder
I've created a Custom Proxy and added a class mediator and log Mediator in it. I'm trying to set a property's value in the java class and need to write that in the log, as the proxy gets deployed. But, so far, haven't got any success.
I've tried adding a parameter in the Log mediator and used the get-property() method but it still doesn't print it. If I use a 'Property' mediator itself, then I'm able to write the value in the log but that's not our purpose here.
I've also tried using log.debug in the java class, just to write the usual 'entering/exiting a function', but to no respite.
Could anyone please help?
How are you setting a property in the java class(ie: in your class mediator)?
It should be like;
synapseMesssageContext.setProperty(key,value);
Then,In the sequence flow access it as;
<property xmlns:ns="http://org.apache.synapse/xsd" name="testing the property"
expression="get-property('key')" scope="default"/>
You can use log.info to print any log messages. Please reffer [1] which has logged messages using log.info.
[1]http://wso2.org/library/2898
I am trying to do something that seems straightforward but can't get it to work. Basically I want the WSO2 API manager to add a URL parameter to a REST call.
Setup and Problem
I have a WSO2 API manager installed. I also have a Tomcat running with a bogus servlet called someservlet that simply logs anything it receives and returns ok. I have added the servlet as an API in the manager, so I can either call the servlet directly or via WSO2 API mgr.
I can run
curl http://localhost:8080/someservlet/servlet/toto?blob=blib&secret=pass
and the servlet works fine, it tells me it's received the path /toto and parameters blob and secret.
I can run
curl -H "Authorization: Bearer [...]" --url "http://192.168.23.1:8280/someservlet/1.0/toto?blob=blib&secret=pass"
And it does exactly the same. So far, so good.
What I want is to run:
curl -H "Authorization: Bearer MqVQuHqLNphtPV3XF1CtXVmbyP8a" --url "http://192.168.23.1:8280/someservlet/1.0/toto?blob=blib"
(note that I've removed the secret parameter)
...and still get the same result.
So basically I want API manager to add the URL parameter secret=pass.
First thing I tried: property mediator
Use Synapse XML config with property REST_URL_POSTFIX.
I edited the API config file, and added
<property name="REST_URL_POSTFIX" value="/blob?toto=titi" scope="axis2" type="STRING"/>
Now if I run
curl -H "Authorization: Bearer [...]" --url "http://192.168.23.1:8280/someservlet/1.0/toti?blab=blib&secret=puss"
it's as if I ran someservlet/1.0/blob?toto=titi: all my path and parameters have disappeared and been repaced with the configured ones. Hey, that's how it's supposed to work, isn't it!
Problems:
this doesn't add something to the URL, it sets the URL postfix, meaning that existing parameters disappear (in the above example, blab=blib)
it has to start with a "/" to be a valid value, so I can't just add &secret=pass (of course, because of problem 1, this would be useless anyway)
So basically this doesn't enable me to append the final &secret=pass.
Second thing I tried: rewrite URL mediator
I found this mediator, and although it probably won't do the trick, it's a good lead: I can just call with secret=foo, and get the mediator to replace it with secret=pass.
I put this in the config file:
<rewrite>
<rewriterule>
<action type="replace" value="pass" fragment="query" regex="foo"/>
</rewriterule>
</rewrite>
This doesn't work. At first I thought I didn't have the action parameters right. But the error message is:
Malformed URL when processing /someservlet/1.0/toti?blab=blib&secret=foo
Malformed? There's more detail in the exception stack trace:
java.net.MalformedURLException: no protocol: /someservlet/1.0/toti?blab=blib&secret=foo
So what's happening is that the mediators (log or rewrite) receive a message whose "To:" field points to a URL with no protocol!
Of course I've been googling around, and there are some cases where I find other people have logMediator: To: /blabla, and other (most) cases where they have logMediator: To: http ://blabla. I don't really see what's causing the difference. :-(
So this is where I'm stuck!! :-(
Option to be tried
I'm aware that there's probably a sledgehammer solution that should work:
use property to store the full path and all parameters
implement my own mediator (e.g. in Java) to modify these parameters
use property REST_URL_POSTFIX to put the modified postfix on the call
However I feel that this problem should have a simpler solution.
I have a kind of hope that someone will point me to a simple resource (mediator, sample, syntax error, anything) that I haven't found and that does just what I want. Optimism... :-)
Thanks for reading. Any ideas?
As i understood, you are trying to append the secret=pass to your endpoint url.
When you invoke the API , i belive you are sending that parameter.
Same time you are sending "blab=blib" parameter also. But in the ESB you need to change that to "toto=titi"
The method you used is right.(ie: Using property REST_URL_POSTFIX) In that case it will replace all requets parameter.
But before using that, you can save the request parameter and using the "REST_URL_POSTFIX"
you can achive the final REST url you need. (yes, that is the final option you mentioned as "to be tried")
In the "TO" address, you will only have address after port number.
If you use "" POST_TO_URI" property yopu will see the full adress URL printed in the log, but we use that if there is any proxy server configured between BE service and ESB
I've solved my problem.
Here's what I do:
in the config file, get the URL postfix using REST_URL_POSTFIX and
put it in a property
edit the property in a Java mediator
use REST_URL_POSTFIX to set the new postfix in XML
For the 1rst step, I use this line:
<property name="querystrings" expression="get-property('axis2', 'REST_URL_POSTFIX')"/>
this took some time to corner, because there are many lines out there that don't work for me, it took the 2 parameters (axis2 and REST...) to get it straight.
For the second step, this is the config XML:
<class name="mypackage.AddUrlParamMediator">
<property name="paramName" value="mykey"/>
<property name="paramValue" value="mysecret"/>
</class>
this is the mediator class (without imports):
public class AddUrlParamMediator extends AbstractMediator {
private String paramName = "default";
private String paramValue = "default";
public void setParamName(String paramName) {
this.paramName = paramName;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public boolean mediate(MessageContext synapseMsgContext) {
SynapseLog log = this.getLog(synapseMsgContext);
String urlNewParam = this.paramName + "=" + this.paramValue;
Object queryStringsPpty = synapseMsgContext.getProperty("querystrings");
if (queryStringsPpty == null) {
log.error("### queryStringPpty=null, exiting!");
return true;
}
String queryStrings = queryStringsPpty.toString();
queryStrings = (queryStrings.contains("?"))
? queryStrings + "&" + urlNewParam
: queryStrings + "?" + urlNewParam;
synapseMsgContext.setProperty("querystrings", queryStrings);
return true;
}
}
and of course here's the third step in the XML config:
<property name="REST_URL_POSTFIX" expression="get-property('querystrings')" scope="axis2" type="STRING"/>
So all this basically sets a parameter at the end of the URL.
Hope this helps others.
For anyone who may have the same issue, here's another solution, simpler and works.
Go to the carbon admin portal, to the list of APIs, find the relevant API and click on it.
This leads to the XML config of the API.
After the "address" field (and at the same level in the XML) add the field:
<property name="Authorization" value="stuff to add" scope="transport"/>
This adds the property "Authorization" with value "stuff".