Skip to content

Instantly share code, notes, and snippets.

@mefarazath
Created November 21, 2016 06:49
Show Gist options
  • Save mefarazath/46cde05ffe6f5a886b72fa5e72b98a32 to your computer and use it in GitHub Desktop.
Save mefarazath/46cde05ffe6f5a886b72fa5e72b98a32 to your computer and use it in GitHub Desktop.
@Path ("/basicAuth")
@Source (interface="default")
package org.iml.authenticators;
constant endpoint authEP = new EndPoint("http://localhost:8290/authenticate/");
constant endpoint spResponseEP = new EndPoint("http://localhost:8290/travelocity/response");
@POST
@Path ("/")
resource login (message m) {
log(level="custom", msg="Basic Authenticator Is HIT !@@@");
m = func: getLoginPage(m);
// send the login page to the browser
reply m;
}
@POST
@Path ("/callback")
resource callback (message m) {
m = AuthenticationResponseProcessor(messageRef=m, parameters="isSubject=true,subjectClaim=username,isAttribute=true");
log(level="custom", msg="Authentication Handled by Basic Authenticator");
m = invoke(endpointRef=spResponseEP, messageRef=m);
}
@Description "Redirect to login Page"
function getLoginPage(message m) (message) throws Exception {
m = AuthenticationRequestBuilder(
messageRef=m,
parameters="authep=http://localhost:8290/authenticate/,
callbackURL=http://localhost:8290/basicAuth/callback"
);
log(level="custom", msg="Authentication Request Ready");
return m;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment