Remove Client via Rest API - keycloak

I am using the:
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>11.0.0</version>
</dependency>
I would like in a programmatic way to remove the Client.
Unfortunately as I see ClientsResource from keycloak.realm("my-realm").clients() has only create option:
#POST
#Consumes(MediaType.APPLICATION_JSON)
Response create(ClientRepresentation clientRepresentation);
Is there any way to remove the client using REST API? Or lack of this option is intentional?

Based on docs there is such API: DELETE /{realm}/clients/{id}.
keycloak.realm("realm").clients().get("id").remove();

Related

Get POST request data from filter in Enonic

Are there any ways to use one method for all post requests instead of having controllers for each post request? Can we use HTTP filters in Enonic to support POST requests? They support GET requests by default.
Yes, you can use "Mappings" in the Site descriptor to intercept e.g. a path.
<site>
<mappings>
<mapping controller="/site/foobar/api.js" order="10">
<pattern>/api/v\d+/.*</pattern>
</mapping>
</mappings>
</site>

E*Trade API Streaming with CometD

I have been using a .net library to create an oauth session, and submit, modify and cancel orders using the ETRADE api. Now I need to listen for account & order events. As per the ETRADE API documentation, they use CometD & long poling. I did find a .net CometD implementation. However, the ETRADE API docs says that one must pass some oauthHeader to initialize the CometD session. Does anyone know exactly what that oauthHeader is? Any sample code would be appreciated.
I modified to the oauth .net library to provide the same oauth header that gets passed to other API http requests:
public string GetOauthAuthorizationHeader(string url)
{
NameValueCollection headers = _session.Request(_accessToken).Post().ForUrl(url).GetRequestDescription().Headers;
return headers[Parameters.OAuth_Authorization_Header];
}
Passing this header to cometd works. I did have to change to a different .net commetd library (nthachus's commetd.net), though; the one I was previously using was ignoring these headers.

Sending the post method contents in REST invocation from WSO2 ESB

I have been trying to invoke a rest operation from my wso2 ESB and was successful in invoking the rest post method from WSO2 ESB. But, un luckily i was not able to access the data that i posted, neither through request parameters nor through request attributes.
PS: I don't want to frame a get kind of URLs for my post request.
is there a solution to this ?
You need to use the correct content type so it will preserve POST request data.This post will help you to understand the reason.
Edit.
1) Add the following entry to axis2.xml in message builders.
<messageBuilder contentType="application/x-www-form-urlencoded"
class="org.apache.synapse.commons.builders.XFormURLEncodedBuilder"/>
2) then access the required parameter in esb using
<property name="NameOfTheProperty" expression="//xformValues/NameOfTheProperty/text()"/>

Prelogin filter before j_security_check

I currently have a form based login in my application which is developed on Jboss portal server. I wish to do some pre login validation and redirect user to another page in case of a condition being true.
How can I intercept the request before j_security_check login is executed and also forward the flow to j_security_check after that condition is found to be false.
Please note that I do not want to have client side validation.
This is what I was trying to do, but didn't find any success:
Created a LoginFilter.java file and my webapp web.xml looked like:
<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>com.xxx.filter.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<url-pattern>j_security_check</url-pattern>
</filter-mapping>
but this filter is not being called at all.
Can anyone tell me what is the issue in this code or any alternative approach to solve this issue.
You wont be able to intercept j_security_check from Serverside. Filters and all will be called only after j_security_check passed , if your resource is secured.
I had similar case , I changed the way my application was making calls. First make a http request to do j_security_check and then use same client instance to do rest of the work.
The bottom line is that , j_security_check is the first thing happens are server. So you wont be able to intercept it from Serverside.
Thanks
J

Add Request SOAP-Header to Response

I am working on an bottom up web service for axis2 deployed on tomcat.
The processing is all working, but for tracking purposes I would like to include some meta data using the Soap Header. Do you know how to make axis2 include the header received into the response? E.g. I would like to pass an id with the header and receive it with the response.
The way to handle these scenarios in Axis2 is to use a handler. You can engage your handler to the out flow and do the header adding part is there. This article[1] describes about the axis2 architecture and how to add new handlers using modules.
[1] http://wso2.org/library/articles/extending-axis2