-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for URL redirects in Orchard clients. This will be used for O…
…Auth.
- Loading branch information
Showing
6 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
site Prompt = orc.lib.orchard.Prompt | ||
site Prompt = orc.lib.orchard.Prompt | ||
site Redirect = orc.lib.orchard.Redirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package orc.lib.orchard; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
import orc.error.JavaException; | ||
import orc.error.SiteException; | ||
import orc.error.TokenException; | ||
import orc.runtime.Args; | ||
import orc.runtime.OrcEngine; | ||
import orc.runtime.Token; | ||
import orc.runtime.sites.Site; | ||
|
||
/** | ||
* Redirect the user to a URL. | ||
* @author quark | ||
*/ | ||
public class Redirect extends Site { | ||
/** | ||
* Interface implemented by an engine which can handle | ||
* this site. | ||
* @author quark | ||
*/ | ||
public interface Redirectable { | ||
public void redirect(URL url); | ||
} | ||
@Override | ||
public void callSite(Args args, final Token caller) throws TokenException { | ||
OrcEngine engine = caller.getEngine(); | ||
final String url = args.stringArg(0); | ||
if (!(engine instanceof Redirectable)) { | ||
caller.error(new SiteException( | ||
"This Orc engine does not support the Redirect site.")); | ||
} | ||
try { | ||
((Redirectable)engine).redirect(new URL(url)); | ||
caller.resume(signal()); | ||
} catch (MalformedURLException e) { | ||
caller.error(new JavaException(e)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package orc.orchard; | ||
|
||
import java.net.URL; | ||
|
||
public class RedirectEvent extends JobEvent { | ||
public URL url; | ||
|
||
public RedirectEvent() {} | ||
|
||
public RedirectEvent(URL url) { | ||
this.url = url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters