From 6d35044d27c2556a0971d3b5bb7091aaee8609e2 Mon Sep 17 00:00:00 2001 From: Brian Remmington Date: Tue, 6 Dec 2011 16:26:29 +0000 Subject: [PATCH] ALF-11550: Added service provider's redirect URL into JSON response from channels.POST and channel-reauth.POST webscripts. Adjusted the ChannelType interface as necessary to make this possible. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32575 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repository/publishing/channel-reauth.post.desc.xml | 2 ++ .../repository/publishing/channels.post.desc.xml | 2 ++ .../alfresco/repository/publishing/publishing.lib.ftl | 1 + .../web/scripts/publishing/AuthCallbackWebScript.java | 2 +- .../repo/web/scripts/publishing/ChannelAuthHelper.java | 9 ++++++--- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.desc.xml index 529acbb349..3e0f325d61 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/channel-reauth.post.desc.xml @@ -15,6 +15,7 @@
channelId
the identifier of the publishing channel
authoriseUrl
The URL to send the user to in order for them to authorise access to the channel
authCallbackUrl
The URL to return the channel authorisation details to
+
authRedirectUrl
The URL that the channel service provider will try to redirect the user to
]]> /api/publishing/channels/{store_protocol}/{store_id}/{node_id}/reauthorise @@ -47,6 +48,7 @@ "channelId": string, "authoriseUrl": string "authCallbackUrl": string + "authRedirectUrl": string } } ]]> diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.desc.xml index 51244895ff..727a23937b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/channels.post.desc.xml @@ -15,6 +15,7 @@
pollUrl
The URL to poll to discover whether the channel has been authorised
authoriseUrl
The URL to send the user to in order for them to authorise access to the channel
authCallbackUrl
The URL to return the channel authorisation details to
+
authRedirectUrl
The URL to which the channel service provider will redirect the user upon authorisation
]]> @@ -49,6 +50,7 @@ "channelId": string, "authoriseUrl": string "authCallbackUrl": string + "authRedirectUrl": string } } ]]> diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing.lib.ftl index b707b9bc5e..9348838809 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/publishing/publishing.lib.ftl @@ -153,6 +153,7 @@ "channelId" : "${channelId}", "authoriseUrl": "${authoriseUrl}", "authCallbackUrl": "${authCallbackUrl}" + "authRedirectUrl": "${authRedirectUrl}" } diff --git a/source/java/org/alfresco/repo/web/scripts/publishing/AuthCallbackWebScript.java b/source/java/org/alfresco/repo/web/scripts/publishing/AuthCallbackWebScript.java index dfec785a0b..76c03dba98 100644 --- a/source/java/org/alfresco/repo/web/scripts/publishing/AuthCallbackWebScript.java +++ b/source/java/org/alfresco/repo/web/scripts/publishing/AuthCallbackWebScript.java @@ -90,7 +90,7 @@ public class AuthCallbackWebScript extends DeclarativeWebScript if (ChannelType.AuthStatus.RETRY.equals(authStatus)) { - String authoriseUrl = channel.getChannelType().getAuthorisationUrl(channel, channelAuthHelper.getAuthoriseCallbackUrl(channelNodeRef)); + String authoriseUrl = channel.getChannelType().getAuthorisationUrls(channel, channelAuthHelper.getAuthoriseCallbackUrl(channelNodeRef)); if (authoriseUrl == null) { authoriseUrl = channelAuthHelper.getDefaultAuthoriseUrl(channelNodeRef); diff --git a/source/java/org/alfresco/repo/web/scripts/publishing/ChannelAuthHelper.java b/source/java/org/alfresco/repo/web/scripts/publishing/ChannelAuthHelper.java index 4e6a0684ef..63f61767ab 100644 --- a/source/java/org/alfresco/repo/web/scripts/publishing/ChannelAuthHelper.java +++ b/source/java/org/alfresco/repo/web/scripts/publishing/ChannelAuthHelper.java @@ -23,6 +23,7 @@ import java.util.TreeMap; import org.alfresco.repo.admin.SysAdminParams; import org.alfresco.service.cmr.publishing.channels.Channel; +import org.alfresco.service.cmr.publishing.channels.ChannelType; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.util.UrlUtil; @@ -71,8 +72,9 @@ public class ChannelAuthHelper public Map buildAuthorisationModel(Channel channel) { - String callbackUrl = getAuthoriseCallbackUrl(channel.getNodeRef()); - String authoriseUrl = channel.getChannelType().getAuthorisationUrl(channel, callbackUrl); + String alfrescoCallbackUrl = getAuthoriseCallbackUrl(channel.getNodeRef()); + ChannelType.AuthUrlPair authUrlPair = channel.getChannelType().getAuthorisationUrls(channel, alfrescoCallbackUrl); + String authoriseUrl = authUrlPair.authorisationRequestUrl; if (authoriseUrl == null) { // If a channel type returns null as the authorise URL then we @@ -84,7 +86,8 @@ public class ChannelAuthHelper Map model = new TreeMap(); model.put("authoriseUrl", authoriseUrl); model.put("channelId", channel.getId()); - model.put("authCallbackUrl", callbackUrl); + model.put("authCallbackUrl", alfrescoCallbackUrl); + model.put("authRedirectUrl", authUrlPair.authorisationRedirectUrl); return model; } }