Skip to content

Instantly share code, notes, and snippets.

//Junit fails to realize that an exception is actually thrown
@Test
public void testOtherRequest() throws Exception {
when(this.request.getServletPath()).thenReturn("/corsAuthorization");
when(this.request.getHeader(CORS.ORIGIN)).thenReturn(null);
thrown.expect(RuntimeException.class);
thrown.expectMessage("Generic HTTP requests not allowed");
public class SysLoggingEventListenerProvider implements EventListenerProvider {
private final SyslogIF syslogger;
public SysLoggingEventListenerProvider(SyslogIF syslogger) {
this.syslogger = syslogger;
}
@Override
public void onEvent(Event event) {
// Actual requirement keeping method signatures same
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import junit.framework.TestCase;
import org.jboss.resteasy.spi.HttpRequest;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.keycloak.services.resources.Cors;
/*For Authorization:
picketlink-api
org.picketlink.config.http.AuthorizationConfiguration
org.picketlink.config.http.AuthorizationConfigurationBuilder
org.picketlink.http.authorization.PathAuthorizer
picketlink-impl
org.picketlink.http.internal.authorization.AbstractPathAuthorizer implements PathAuthorizer
LINE 152 SCIMSchema.java / System.out.println("\n"+javaType+" "+result.size() + " "+attribute.getName());
class [Ljava.lang.String; 0 externalId
class org.picketlink.scim.model.v11.schema.SCIMGroupSchema$Members 3 members
class org.picketlink.scim.model.v11.schema.SCIMUserSchema$Ims 4 ims
class org.picketlink.scim.model.v11.schema.SCIMUserSchema$Emails 4 emails
cors.allowGenericHttpRequests=true
cors.allowOrigin=https://www.example.org:9000, http://example.com:8008
cors.allowSubdomains=false
cors.supportedMethods=GET, PUT, HEAD, POST, DELETE, OPTIONS
cors.supportedHeaders=Origin, X-Requested-With, Content-Type, Accept, Authorization
cors.exposedHeaders=
cors.supportsCredentials=true
cors.maxAge=3600
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>CORS demo</display-name>
/*Existing Implementation of REST Endpoints:
UserEndpoint
//Create an user
Reads JSON representation of user from a file SCIMUser.json, parses it into
SCIMUser object(includes lot of details about scimuser) and
populates PL IDM User object with basic information(id, loginName, firstName, lastName)
with the help of SCIMUser and stores user it in identityManager. Sends back String representation
of SCIMUser as JSON.
//Declaration of @annotation_A depends on @annotation_B means that annotation_B can only be declared if annotation_A is declared.
//Also, declaration of annotation_A must precede annotation_B
@PicketlinkHttpSecurity
public interface Security {
static enum Secure {
//optional, redundant(as it is a must)
@Http