{"action":"created","comment":{"url":"https://api.github.com/repos/apereo/cas/pulls/comments/128940136","pull_request_review_id":51663215,"id":128940136,"diff_hunk":"@@ -0,0 +1,98 @@\n+package org.apereo.cas.adaptors.fortress;\n+\n+import org.apache.directory.fortress.core.AccessMgr;\n+import org.apache.directory.fortress.core.model.Session;\n+import org.apache.directory.fortress.core.model.User;\n+import org.apereo.cas.authentication.HandlerResult;\n+import org.apereo.cas.authentication.PreventedException;\n+import org.apereo.cas.authentication.UsernamePasswordCredential;\n+import org.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler;\n+import org.apereo.cas.authentication.principal.PrincipalFactory;\n+import org.apereo.cas.services.ServicesManager;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.beans.factory.annotation.Qualifier;\n+\n+import javax.security.auth.login.FailedLoginException;\n+import javax.xml.bind.JAXBContext;\n+import javax.xml.bind.JAXBException;\n+import javax.xml.bind.Marshaller;\n+import java.io.StringWriter;\n+import java.security.GeneralSecurityException;\n+import java.util.HashMap;\n+import java.util.Map;\n+\n+/**\n+ * Fortress authentication handler, this class will delegate the authentication to call fortress rest authentication.\n+ *\n+ * @author yudhi.k.surtan\n+ * @since 5.2.0.\n+ */\n+public class FortressAuthenticationHandler extends AbstractUsernamePasswordAuthenticationHandler {\n+    private static final Logger LOGGER = LoggerFactory.getLogger(FortressAuthenticationHandler.class);\n+    private static final String FORTRESS_SESSION_KEY = \"fortressSession\";\n+    private static final String JAXB_EXCEPTION_MESSAGE = \"failed initialize jaxb context\";\n+    private static final String TRACE_ATTEMPT_MESSAGE_TO_FORTRESS = \"trying to delegate authentication for {} to fortress\";\n+    private static final String TRACE_FORTRESS_SESSION_RESPONSE = \"fortress session result : {}\";","path":"support/cas-server-support-fortress/src/main/java/org/apereo/cas/adaptors/fortress/FortressAuthenticationHandler.java","position":37,"original_position":37,"commit_id":"6c131e70bd2445a27a4e50723ce5d2128ed28a8c","original_commit_id":"6c131e70bd2445a27a4e50723ce5d2128ed28a8c","user":{"login":"mmoayyed","id":1205228,"avatar_url":"https://avatars1.githubusercontent.com/u/1205228?v=4","gravatar_id":"","url":"https://api.github.com/users/mmoayyed","html_url":"https://github.com/mmoayyed","followers_url":"https://api.github.com/users/mmoayyed/followers","following_url":"https://api.github.com/users/mmoayyed/following{/other_user}","gists_url":"https://api.github.com/users/mmoayyed/gists{/gist_id}","starred_url":"https://api.github.com/users/mmoayyed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmoayyed/subscriptions","organizations_url":"https://api.github.com/users/mmoayyed/orgs","repos_url":"https://api.github.com/users/mmoayyed/repos","events_url":"https://api.github.com/users/mmoayyed/events{/privacy}","received_events_url":"https://api.github.com/users/mmoayyed/received_events","type":"User","site_admin":false},"body":"Use `[{}]` instead","created_at":"2017-07-24T02:27:27Z","updated_at":"2017-07-24T02:27:28Z","html_url":"https://github.com/apereo/cas/pull/2636#discussion_r128940136","pull_request_url":"https://api.github.com/repos/apereo/cas/pulls/2636","_links":{"self":{"href":"https://api.github.com/repos/apereo/cas/pulls/comments/128940136"},"html":{"href":"https://github.com/apereo/cas/pull/2636#discussion_r128940136"},"pull_request":{"href":"https://api.github.com/repos/apereo/cas/pulls/2636"}}},"pull_request":{"url":"https://api.github.com/repos/apereo/cas/pulls/2636","id":122758676,"html_url":"https://github.com/apereo/cas/pull/2636","diff_url":"https://github.com/apereo/cas/pull/2636.diff","patch_url":"https://github.com/apereo/cas/pull/2636.patch","issue_url":"https://api.github.com/repos/apereo/cas/issues/2636","number":2636,"state":"open","locked":false,"title":"porting cas fortress integration using spring boot","user":{"login":"yudhik","id":493782,"avatar_url":"https://avatars2.githubusercontent.com/u/493782?v=4","gravatar_id":"","url":"https://api.github.com/users/yudhik","html_url":"https://github.com/yudhik","followers_url":"https://api.github.com/users/yudhik/followers","following_url":"https://api.github.com/users/yudhik/following{/other_user}","gists_url":"https://api.github.com/users/yudhik/gists{/gist_id}","starred_url":"https://api.github.com/users/yudhik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yudhik/subscriptions","organizations_url":"https://api.github.com/users/yudhik/orgs","repos_url":"https://api.github.com/users/yudhik/repos","events_url":"https://api.github.com/users/yudhik/events{/privacy}","received_events_url":"https://api.github.com/users/yudhik/received_events","type":"User","site_admin":false},"body":"Closes #1245 \r\n\r\nHi Misagh,\r\n\r\nRegarding to Cas Fortress Integration, I did some porting code to my repository and did this pull request review to apereo cas repository.\r\nHonestly i'm a bit surprise since the new CAS version has moved to spring boot and unfortunately i'm not yet familiar with spring boot life cycle and design.\r\nHere the picture of how my current production CAS communicate with fortress.\r\n![cas-fortress-integration-sequence-diagram](https://cloud.githubusercontent.com/assets/493782/26521160/f9987de0-430b-11e7-833d-a0e6257a9ebd.PNG)\r\n\r\nIf you see that picture, there you'll find that CAS will delegate the authentication to fortress on behalf fortress admin user, which configured at the fortress.properties file. \r\nSo basically when you use \"**AccessMgr**\" the class will automatically search for the fortress properties at your classpath and construct that class and put admin user as the default communication user to fortress.\r\n\r\nFortress also have a requirement where you need to specified the version value which you can put it at java opts properties or other way around. At my implementation i put it under \"**MethodInvokingFactoryBean**\", below is the example how i did for implement it.\r\n\r\n```\r\n<bean class=\"org.springframework.beans.factory.config.MethodInvokingFactoryBean\">\r\n    <property name=\"targetObject\">\r\n      <bean class=\"org.springframework.beans.factory.config.MethodInvokingFactoryBean\">\r\n        <property name=\"targetClass\" value=\"java.lang.System\" />\r\n        <property name=\"targetMethod\" value=\"getProperties\" />\r\n      </bean>\r\n    </property>\r\n    <property name=\"targetMethod\" value=\"putAll\" />\r\n    <property name=\"arguments\">\r\n      <util:properties>\r\n        <prop key=\"version\">1.0.0</prop>\r\n      </util:properties>\r\n    </property>\r\n</bean>\r\n```\r\n\r\nI also modified \"authenticationHandlersResolvers\" map and put my handler implementation with null \"**PrincipalResolver**\" since i'm not using any principal resolver.\r\n\r\n```\r\n<util:map id=\"authenticationHandlersResolvers\">\r\n    <entry key-ref=\"proxyAuthenticationHandler\" value-ref=\"proxyPrincipalResolver\" />\r\n    <entry key-ref=\"iamAuthenticationHandler\">\r\n      <null></null>\r\n    </entry>\r\n</util:map>\r\n```\r\n\r\nwith anyAuthenticationPolicy\r\n\r\n`<alias name=\"anyAuthenticationPolicy\" alias=\"authenticationPolicy\" />`\r\n\r\nIn order to use the handler, i need to register below code.\r\n\r\n```\r\n<bean id=\"iamAccessManager\" class=\"org.apache.directory.fortress.core.rest.AccessMgrRestImpl\">\r\n    <property name=\"contextId\" value=\"HOME\" />\r\n</bean>\r\n<bean id=\"iamAuthenticationHandler\" class=\"com.gdn.iam.cas.IamAuthenticationHandler\">\r\n    <property name=\"accessManager\" ref=\"iamAccessManager\" />\r\n</bean>\r\n```\r\n\r\nAnd after that everything at CAS server will delegate the authentication to fortress.\r\n\r\nNow, let's compare to this pull request implementation.\r\nThere are 5 files modified for the first commit. However there are 1 modification which modified the core one which is CasConfigurationProperties. \r\n**Is it a correct approach in order integrate fortress implementation**?\r\n**Is my the registration of fortress handler correct**? I'm doubt since i'm constructing a new collection for it.\r\n`final Collection<AuthenticationHandler> handlers = new HashSet<>();`\r\n\r\nPlease let me know if the implementation is correct or not, i will make a unit test if this is correct and test it in my local environment.","created_at":"2017-05-27T11:47:57Z","updated_at":"2017-07-24T02:27:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"150c62304257cec0d66e5137a7822a53d11f953e","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":{"url":"https://api.github.com/repos/apereo/cas/milestones/56","html_url":"https://github.com/apereo/cas/milestone/56","labels_url":"https://api.github.com/repos/apereo/cas/milestones/56/labels","id":2546415,"number":56,"title":"5.2.0-RC2","description":"","creator":{"login":"mmoayyed","id":1205228,"avatar_url":"https://avatars1.githubusercontent.com/u/1205228?v=4","gravatar_id":"","url":"https://api.github.com/users/mmoayyed","html_url":"https://github.com/mmoayyed","followers_url":"https://api.github.com/users/mmoayyed/followers","following_url":"https://api.github.com/users/mmoayyed/following{/other_user}","gists_url":"https://api.github.com/users/mmoayyed/gists{/gist_id}","starred_url":"https://api.github.com/users/mmoayyed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmoayyed/subscriptions","organizations_url":"https://api.github.com/users/mmoayyed/orgs","repos_url":"https://api.github.com/users/mmoayyed/repos","events_url":"https://api.github.com/users/mmoayyed/events{/privacy}","received_events_url":"https://api.github.com/users/mmoayyed/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":33,"state":"open","created_at":"2017-05-27T18:14:01Z","updated_at":"2017-07-21T13:26:36Z","due_on":"2017-07-28T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/apereo/cas/pulls/2636/commits","review_comments_url":"https://api.github.com/repos/apereo/cas/pulls/2636/comments","review_comment_url":"https://api.github.com/repos/apereo/cas/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apereo/cas/issues/2636/comments","statuses_url":"https://api.github.com/repos/apereo/cas/statuses/6c131e70bd2445a27a4e50723ce5d2128ed28a8c","head":{"label":"bliblidotcom:cas-1245","ref":"cas-1245","sha":"6c131e70bd2445a27a4e50723ce5d2128ed28a8c","user":{"login":"bliblidotcom","id":11690962,"avatar_url":"https://avatars1.githubusercontent.com/u/11690962?v=4","gravatar_id":"","url":"https://api.github.com/users/bliblidotcom","html_url":"https://github.com/bliblidotcom","followers_url":"https://api.github.com/users/bliblidotcom/followers","following_url":"https://api.github.com/users/bliblidotcom/following{/other_user}","gists_url":"https://api.github.com/users/bliblidotcom/gists{/gist_id}","starred_url":"https://api.github.com/users/bliblidotcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bliblidotcom/subscriptions","organizations_url":"https://api.github.com/users/bliblidotcom/orgs","repos_url":"https://api.github.com/users/bliblidotcom/repos","events_url":"https://api.github.com/users/bliblidotcom/events{/privacy}","received_events_url":"https://api.github.com/users/bliblidotcom/received_events","type":"Organization","site_admin":false},"repo":{"id":91102648,"name":"cas","full_name":"bliblidotcom/cas","owner":{"login":"bliblidotcom","id":11690962,"avatar_url":"https://avatars1.githubusercontent.com/u/11690962?v=4","gravatar_id":"","url":"https://api.github.com/users/bliblidotcom","html_url":"https://github.com/bliblidotcom","followers_url":"https://api.github.com/users/bliblidotcom/followers","following_url":"https://api.github.com/users/bliblidotcom/following{/other_user}","gists_url":"https://api.github.com/users/bliblidotcom/gists{/gist_id}","starred_url":"https://api.github.com/users/bliblidotcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bliblidotcom/subscriptions","organizations_url":"https://api.github.com/users/bliblidotcom/orgs","repos_url":"https://api.github.com/users/bliblidotcom/repos","events_url":"https://api.github.com/users/bliblidotcom/events{/privacy}","received_events_url":"https://api.github.com/users/bliblidotcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bliblidotcom/cas","description":"Apereo CAS - Enterprise Single Sign On for all earthlings and beyond.","fork":true,"url":"https://api.github.com/repos/bliblidotcom/cas","forks_url":"https://api.github.com/repos/bliblidotcom/cas/forks","keys_url":"https://api.github.com/repos/bliblidotcom/cas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bliblidotcom/cas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bliblidotcom/cas/teams","hooks_url":"https://api.github.com/repos/bliblidotcom/cas/hooks","issue_events_url":"https://api.github.com/repos/bliblidotcom/cas/issues/events{/number}","events_url":"https://api.github.com/repos/bliblidotcom/cas/events","assignees_url":"https://api.github.com/repos/bliblidotcom/cas/assignees{/user}","branches_url":"https://api.github.com/repos/bliblidotcom/cas/branches{/branch}","tags_url":"https://api.github.com/repos/bliblidotcom/cas/tags","blobs_url":"https://api.github.com/repos/bliblidotcom/cas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bliblidotcom/cas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bliblidotcom/cas/git/refs{/sha}","trees_url":"https://api.github.com/repos/bliblidotcom/cas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bliblidotcom/cas/statuses/{sha}","languages_url":"https://api.github.com/repos/bliblidotcom/cas/languages","stargazers_url":"https://api.github.com/repos/bliblidotcom/cas/stargazers","contributors_url":"https://api.github.com/repos/bliblidotcom/cas/contributors","subscribers_url":"https://api.github.com/repos/bliblidotcom/cas/subscribers","subscription_url":"https://api.github.com/repos/bliblidotcom/cas/subscription","commits_url":"https://api.github.com/repos/bliblidotcom/cas/commits{/sha}","git_commits_url":"https://api.github.com/repos/bliblidotcom/cas/git/commits{/sha}","comments_url":"https://api.github.com/repos/bliblidotcom/cas/comments{/number}","issue_comment_url":"https://api.github.com/repos/bliblidotcom/cas/issues/comments{/number}","contents_url":"https://api.github.com/repos/bliblidotcom/cas/contents/{+path}","compare_url":"https://api.github.com/repos/bliblidotcom/cas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bliblidotcom/cas/merges","archive_url":"https://api.github.com/repos/bliblidotcom/cas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bliblidotcom/cas/downloads","issues_url":"https://api.github.com/repos/bliblidotcom/cas/issues{/number}","pulls_url":"https://api.github.com/repos/bliblidotcom/cas/pulls{/number}","milestones_url":"https://api.github.com/repos/bliblidotcom/cas/milestones{/number}","notifications_url":"https://api.github.com/repos/bliblidotcom/cas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bliblidotcom/cas/labels{/name}","releases_url":"https://api.github.com/repos/bliblidotcom/cas/releases{/id}","deployments_url":"https://api.github.com/repos/bliblidotcom/cas/deployments","created_at":"2017-05-12T15:01:11Z","updated_at":"2017-07-12T06:32:33Z","pushed_at":"2017-07-23T16:39:26Z","git_url":"git://github.com/bliblidotcom/cas.git","ssh_url":"git@github.com:bliblidotcom/cas.git","clone_url":"https://github.com/bliblidotcom/cas.git","svn_url":"https://github.com/bliblidotcom/cas","homepage":"https://apereo.github.io/cas/","size":1312366,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apereo:master","ref":"master","sha":"4e390717ca5966059945b72111d36b390f0d8300","user":{"login":"apereo","id":4679233,"avatar_url":"https://avatars3.githubusercontent.com/u/4679233?v=4","gravatar_id":"","url":"https://api.github.com/users/apereo","html_url":"https://github.com/apereo","followers_url":"https://api.github.com/users/apereo/followers","following_url":"https://api.github.com/users/apereo/following{/other_user}","gists_url":"https://api.github.com/users/apereo/gists{/gist_id}","starred_url":"https://api.github.com/users/apereo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apereo/subscriptions","organizations_url":"https://api.github.com/users/apereo/orgs","repos_url":"https://api.github.com/users/apereo/repos","events_url":"https://api.github.com/users/apereo/events{/privacy}","received_events_url":"https://api.github.com/users/apereo/received_events","type":"Organization","site_admin":false},"repo":{"id":2352744,"name":"cas","full_name":"apereo/cas","owner":{"login":"apereo","id":4679233,"avatar_url":"https://avatars3.githubusercontent.com/u/4679233?v=4","gravatar_id":"","url":"https://api.github.com/users/apereo","html_url":"https://github.com/apereo","followers_url":"https://api.github.com/users/apereo/followers","following_url":"https://api.github.com/users/apereo/following{/other_user}","gists_url":"https://api.github.com/users/apereo/gists{/gist_id}","starred_url":"https://api.github.com/users/apereo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apereo/subscriptions","organizations_url":"https://api.github.com/users/apereo/orgs","repos_url":"https://api.github.com/users/apereo/repos","events_url":"https://api.github.com/users/apereo/events{/privacy}","received_events_url":"https://api.github.com/users/apereo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apereo/cas","description":"Apereo CAS - Enterprise Single Sign On for all earthlings and beyond.","fork":false,"url":"https://api.github.com/repos/apereo/cas","forks_url":"https://api.github.com/repos/apereo/cas/forks","keys_url":"https://api.github.com/repos/apereo/cas/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apereo/cas/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apereo/cas/teams","hooks_url":"https://api.github.com/repos/apereo/cas/hooks","issue_events_url":"https://api.github.com/repos/apereo/cas/issues/events{/number}","events_url":"https://api.github.com/repos/apereo/cas/events","assignees_url":"https://api.github.com/repos/apereo/cas/assignees{/user}","branches_url":"https://api.github.com/repos/apereo/cas/branches{/branch}","tags_url":"https://api.github.com/repos/apereo/cas/tags","blobs_url":"https://api.github.com/repos/apereo/cas/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apereo/cas/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apereo/cas/git/refs{/sha}","trees_url":"https://api.github.com/repos/apereo/cas/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apereo/cas/statuses/{sha}","languages_url":"https://api.github.com/repos/apereo/cas/languages","stargazers_url":"https://api.github.com/repos/apereo/cas/stargazers","contributors_url":"https://api.github.com/repos/apereo/cas/contributors","subscribers_url":"https://api.github.com/repos/apereo/cas/subscribers","subscription_url":"https://api.github.com/repos/apereo/cas/subscription","commits_url":"https://api.github.com/repos/apereo/cas/commits{/sha}","git_commits_url":"https://api.github.com/repos/apereo/cas/git/commits{/sha}","comments_url":"https://api.github.com/repos/apereo/cas/comments{/number}","issue_comment_url":"https://api.github.com/repos/apereo/cas/issues/comments{/number}","contents_url":"https://api.github.com/repos/apereo/cas/contents/{+path}","compare_url":"https://api.github.com/repos/apereo/cas/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apereo/cas/merges","archive_url":"https://api.github.com/repos/apereo/cas/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apereo/cas/downloads","issues_url":"https://api.github.com/repos/apereo/cas/issues{/number}","pulls_url":"https://api.github.com/repos/apereo/cas/pulls{/number}","milestones_url":"https://api.github.com/repos/apereo/cas/milestones{/number}","notifications_url":"https://api.github.com/repos/apereo/cas/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apereo/cas/labels{/name}","releases_url":"https://api.github.com/repos/apereo/cas/releases{/id}","deployments_url":"https://api.github.com/repos/apereo/cas/deployments","created_at":"2011-09-09T01:36:42Z","updated_at":"2017-07-22T19:20:09Z","pushed_at":"2017-07-24T02:24:43Z","git_url":"git://github.com/apereo/cas.git","ssh_url":"git@github.com:apereo/cas.git","clone_url":"https://github.com/apereo/cas.git","svn_url":"https://github.com/apereo/cas","homepage":"https://apereo.github.io/cas/","size":1312672,"stargazers_count":2846,"watchers_count":2846,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1633,"mirror_url":null,"open_issues_count":8,"forks":1633,"open_issues":8,"watchers":2846,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apereo/cas/pulls/2636"},"html":{"href":"https://github.com/apereo/cas/pull/2636"},"issue":{"href":"https://api.github.com/repos/apereo/cas/issues/2636"},"comments":{"href":"https://api.github.com/repos/apereo/cas/issues/2636/comments"},"review_comments":{"href":"https://api.github.com/repos/apereo/cas/pulls/2636/comments"},"review_comment":{"href":"https://api.github.com/repos/apereo/cas/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apereo/cas/pulls/2636/commits"},"statuses":{"href":"https://api.github.com/repos/apereo/cas/statuses/6c131e70bd2445a27a4e50723ce5d2128ed28a8c"}}}}
{"actor":{"display_login":"mmoayyed"}}