[asterisk-scf-commits] team/dlee/fosdem2011.git branch "master" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Feb 8 09:49:16 CST 2011
branch "master" has been created
at 1d975d19d1181d4cc99ca79685a218ac762d0023 (commit)
- Log -----------------------------------------------------------------
commit 1d975d19d1181d4cc99ca79685a218ac762d0023
Author: David M. Lee <dlee at digium.com>
Date: Tue Feb 8 09:25:16 2011 -0600
Use Maven for building Java + organized sources.
Since Maven strongly suggests you put your Java sources in
src/main/java, I similarly organized the sources for the other
languages.
diff --git a/.gitignore b/.gitignore
index 297800c..84a72f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-*.class
*.pyc
fred
fred.exe
+target
diff --git a/Makefile b/Makefile
index 93daeb0..7b1dc04 100644
--- a/Makefile
+++ b/Makefile
@@ -1,24 +1,24 @@
-export CLASSPATH=/home/kpfleming/git/asterisk-scf/fosdem:/home/kpfleming/git/asterisk-scf/gitall/slice/java/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
-export PYTHONPATH=/opt/Ice-3.4/python:/home/kpfleming/git/asterisk-scf/gitall/slice/python
+GITALL=/home/kpfleming/git/asterisk-scf/gitall
+export PYTHONPATH=/opt/Ice-3.4/python:$(GITALL)/slice/python
-all: fred.class fred.pyc fred fred.exe
+all: java fred.pyc fred fred.exe
-fred.exe: fred.cs
- gmcs -out:$@ -t:exe -lib:/opt/Ice-3.4/bin -lib:/home/kpfleming/git/asterisk-scf/gitall/slice/mono -r:Ice -r:AsteriskSCF-API $<
+fred.exe: src/main/cs/fred.cs
+ gmcs -out:$@ -t:exe -lib:/opt/Ice-3.4/bin -lib:$(GITALL)/slice/mono -r:Ice -r:AsteriskSCF-API $<
-fred: fred.cpp
+fred: src/main/cpp/fred.cpp
g++ -o $@ -I/opt/Ice-3.4/include -I/usr/local/include -L/opt/Ice-3.4/lib64 -L/usr/local/lib -lIce -lIceUtil -lasterisk-scf-api $<
-fredHook.class: fredHook.java
- javac -Xlint:deprecation $<
+java:
+ mvn package
-fred.class: fred.java fredHook.class
- javac -Xlint:deprecation $<
-
-fred.pyc: fred.py
+fred.pyc: src/main/py/fred.py
python $<
clean:
+ rm -rf target # Maven build artifacts
rm -rf fred.class
rm -rf fredHook.class
rm -rf fred.pyc
+
+.PHONY: java
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..dc7b6a6
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,60 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.asterisk.scf.example</groupId>
+ <artifactId>fred</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>fred</name>
+
+ <dependencies>
+ <dependency>
+ <!--
+ - This dependency must be manually installed in your local Maven
+ - repository.
+ - See https://wiki.asterisk.org/wiki/display/TOP/Building+Java+components
+ -->
+ <groupId>org.asterisk.scf</groupId>
+ <artifactId>api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>fred</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>appassembler-maven-plugin</artifactId>
+ <version>1.1.1</version>
+ <configuration>
+ <programs>
+ <program>
+ <mainClass>fred</mainClass>
+ <name>fred</name>
+ </program>
+ </programs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+</project>
diff --git a/fred.cpp b/src/main/cpp/fred.cpp
similarity index 100%
rename from fred.cpp
rename to src/main/cpp/fred.cpp
diff --git a/fred.cs b/src/main/cs/fred.cs
similarity index 100%
rename from fred.cs
rename to src/main/cs/fred.cs
diff --git a/fred.java b/src/main/java/fred.java
similarity index 100%
rename from fred.java
rename to src/main/java/fred.java
diff --git a/fredHook.java b/src/main/java/fredHook.java
similarity index 100%
rename from fredHook.java
rename to src/main/java/fredHook.java
diff --git a/fred.py b/src/main/py/fred.py
similarity index 100%
rename from fred.py
rename to src/main/py/fred.py
commit 2496daf5cb9635b42b8b82b6d97de09b581c7641
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Mon Feb 7 13:52:02 2011 +0100
And now for completeness... a C# example.
diff --git a/.gitignore b/.gitignore
index fc11bf7..297800c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.class
*.pyc
fred
+fred.exe
diff --git a/Makefile b/Makefile
index 4dd811e..93daeb0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,10 @@
export CLASSPATH=/home/kpfleming/git/asterisk-scf/fosdem:/home/kpfleming/git/asterisk-scf/gitall/slice/java/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
export PYTHONPATH=/opt/Ice-3.4/python:/home/kpfleming/git/asterisk-scf/gitall/slice/python
-all: fred.class fred.pyc fred
+all: fred.class fred.pyc fred fred.exe
+
+fred.exe: fred.cs
+ gmcs -out:$@ -t:exe -lib:/opt/Ice-3.4/bin -lib:/home/kpfleming/git/asterisk-scf/gitall/slice/mono -r:Ice -r:AsteriskSCF-API $<
fred: fred.cpp
g++ -o $@ -I/opt/Ice-3.4/include -I/usr/local/include -L/opt/Ice-3.4/lib64 -L/usr/local/lib -lIce -lIceUtil -lasterisk-scf-api $<
diff --git a/fred.cs b/fred.cs
new file mode 100644
index 0000000..e7338e8
--- /dev/null
+++ b/fred.cs
@@ -0,0 +1,57 @@
+using System;
+using AsteriskSCF.System.Hook.V1;
+using AsteriskSCF.SIP.ExtensionPoint.V1;
+
+public class Fred : Ice.Application
+{
+ public class Hook : AuthHookDisp_
+ {
+ public static Ice.ObjectAdapter _adapter;
+ public AuthHookPrx _proxy;
+
+ public Hook()
+ {
+ _proxy = AuthHookPrxHelper.uncheckedCast(_adapter.addWithUUID(this));
+ }
+
+ public override HookResult challengeRequest(RequestInfo info, out DigestChallenge[] challenges, Ice.Current current)
+ {
+ HookResult result = new HookResult();
+ DigestChallenge challenge = new DigestChallenge();
+
+ challenge.username = "bob";
+ challenge.password = "alice";
+ challenge.domain = new String[]{ "example.com" };
+ challenge.algorithm = DigestAlgorithm.AKAv1MD5;
+
+ challenges = new DigestChallenge[]{ challenge };
+ result.status = HookStatus.Succeeded;
+
+ return result;
+ }
+ }
+
+ public override int run(string[] args)
+ {
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("fred");
+ adapter.activate();
+ Hook._adapter = adapter;
+
+ Hook hook = new Hook();
+
+ // this sample code does not actually locate the target SIP component
+ AuthExtensionPointPrx epPrx = AuthExtensionPointPrxHelper.uncheckedCast(communicator().stringToProxy("sip_component"));
+ HookId _hookId = epPrx.addAuthHook(hook._proxy, new RequestType[]{ RequestType.DialogEstablishing });
+
+ communicator().waitForShutdown();
+ epPrx.removeAuthHook(_hookId);
+
+ return 0;
+ }
+
+ public static void Main(string[] args)
+ {
+ Fred app = new Fred();
+ Environment.Exit(app.main(args));
+ }
+}
commit 78ad76304e3a98dbbe1145b4f63268f8e4d8a830
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Mon Feb 7 13:50:59 2011 +0100
hookId is not a member variable, so don't use an underscore prefix.
Whitespace cleanup to be consistent with other examples.
diff --git a/fred.java b/fred.java
index 563f2f7..8437b37 100644
--- a/fred.java
+++ b/fred.java
@@ -3,8 +3,6 @@ import AsteriskSCF.SIP.ExtensionPoint.V1.*;
public class fred extends Ice.Application
{
- private HookId _hookId;
-
public int run(String[] args)
{
Ice.ObjectAdapter adapter = communicator().createObjectAdapter("fred");
@@ -15,10 +13,10 @@ public class fred extends Ice.Application
// this sample code does not actually locate the target SIP component
AuthExtensionPointPrx epPrx = AuthExtensionPointPrxHelper.uncheckedCast(communicator().stringToProxy("sip_component"));
- _hookId = epPrx.addAuthHook(hook._proxy, new RequestType[]{ RequestType.DialogEstablishing });
+ HookId hookId = epPrx.addAuthHook(hook._proxy, new RequestType[]{ RequestType.DialogEstablishing });
communicator().waitForShutdown();
- epPrx.removeAuthHook(_hookId);
+ epPrx.removeAuthHook(hookId);
return 0;
}
diff --git a/fredHook.java b/fredHook.java
index f0800c5..973aa4e 100644
--- a/fredHook.java
+++ b/fredHook.java
@@ -22,7 +22,6 @@ public class fredHook extends _AuthHookDisp
challenge.algorithm = DigestAlgorithm.AKAv1MD5;
challengeSeq.value = new DigestChallenge[]{ challenge };
-
result.status = HookStatus.Succeeded;
return result;
commit ded5b7e9199c09c5b0c627b53b180e4c19952c6e
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Mon Feb 7 13:50:30 2011 +0100
hookId is not a member variable, so don't use an underscore prefix.
Whitespace cleanup to be consistent with other examples.
diff --git a/fred.py b/fred.py
index b548d05..269024f 100644
--- a/fred.py
+++ b/fred.py
@@ -19,14 +19,11 @@ class fredHook(AuthHook):
challenge.algorithm = DigestAlgorithm.AKAv1MD5
challenges = [ challenge ]
-
result.status = HookStatus.Succeeded
return result
class fred(Ice.Application):
- _hookId = None
-
def run(self, args):
adapter = self.communicator().createObjectAdapter("fred")
adapter.activate()
@@ -36,10 +33,10 @@ class fred(Ice.Application):
# this sample code does not actually locate the target SIP component
epPrx = AuthExtensionPointPrx.uncheckedCast(communicator().stringToProxy("sip_component"))
- _hookId = epPrx.addAuthHook(hook._proxy, [ RequestType.DialogEstablishing ])
+ hookId = epPrx.addAuthHook(hook._proxy, [ RequestType.DialogEstablishing ])
self.communicator().waitForShutdown()
- epPrx.removeAuthHook(_hookId)
+ epPrx.removeAuthHook(hookId)
return 0
commit a055b6f80739c09abdd36b52db146c4dc4b6e2b7
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Mon Feb 7 13:49:40 2011 +0100
hookId is not a member variable, so don't use an underscore prefix.
Whitespace cleanup to be consistent with other examples.
diff --git a/fred.cpp b/fred.cpp
index 79ec162..490aa44 100644
--- a/fred.cpp
+++ b/fred.cpp
@@ -29,8 +29,8 @@ struct fredHook : virtual public AuthHook
challenge->algorithm = AKAv1MD5;
challenges.push_back(challenge);
-
result.status = Succeeded;
+
return result;
}
};
@@ -48,10 +48,10 @@ struct fred : virtual public Ice::Application
AuthExtensionPointPrx epPrx = AuthExtensionPointPrx::uncheckedCast(communicator()->stringToProxy("sip_component"));
RequestTypeSeq requestTypes;
requestTypes.push_back(DialogEstablishing);
- HookId _hookId = epPrx->addAuthHook(hook->_proxy, requestTypes);
+ HookId hookId = epPrx->addAuthHook(hook->_proxy, requestTypes);
communicator()->waitForShutdown();
- epPrx->removeAuthHook(_hookId);
+ epPrx->removeAuthHook(hookId);
return 0;
}
commit ae33998f390fc8b1b3e1e42ce0a689d66edbdfa4
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Sun Feb 6 10:20:52 2011 +0100
Clean up formatting a bit.
Add a C++ example.
diff --git a/.gitignore b/.gitignore
index d1c8995..fc11bf7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.class
*.pyc
+fred
diff --git a/Makefile b/Makefile
index 11864ed..4dd811e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,10 @@
export CLASSPATH=/home/kpfleming/git/asterisk-scf/fosdem:/home/kpfleming/git/asterisk-scf/gitall/slice/java/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
export PYTHONPATH=/opt/Ice-3.4/python:/home/kpfleming/git/asterisk-scf/gitall/slice/python
-all: fred.class fred.pyc
+all: fred.class fred.pyc fred
+
+fred: fred.cpp
+ g++ -o $@ -I/opt/Ice-3.4/include -I/usr/local/include -L/opt/Ice-3.4/lib64 -L/usr/local/lib -lIce -lIceUtil -lasterisk-scf-api $<
fredHook.class: fredHook.java
javac -Xlint:deprecation $<
diff --git a/fred.cpp b/fred.cpp
new file mode 100644
index 0000000..79ec162
--- /dev/null
+++ b/fred.cpp
@@ -0,0 +1,64 @@
+#include <Ice/Ice.h>
+
+#include <AsteriskSCF/System/Hook/HookIf.h>
+#include <AsteriskSCF/SIP/SIPExtensionPointIf.h>
+
+using namespace std;
+using namespace Ice;
+using namespace AsteriskSCF::System::Hook::V1;
+using namespace AsteriskSCF::SIP::ExtensionPoint::V1;
+
+struct fredHook : virtual public AuthHook
+{
+ ObjectAdapterPtr _adapter;
+ AuthHookPrx _proxy;
+
+ fredHook(ObjectAdapterPtr adapter) : _adapter(adapter)
+ {
+ _proxy = AuthHookPrx::uncheckedCast(_adapter->addWithUUID(this));
+ }
+
+ HookResult challengeRequest(const RequestInfoPtr& info, DigestChallengeSeq& challenges, const Ice::Current&)
+ {
+ HookResult result;
+ DigestChallengePtr challenge = new DigestChallenge();
+
+ challenge->username = "bob";
+ challenge->password = "alice";
+ challenge->domain.push_back("example.com");
+ challenge->algorithm = AKAv1MD5;
+
+ challenges.push_back(challenge);
+
+ result.status = Succeeded;
+ return result;
+ }
+};
+
+struct fred : virtual public Ice::Application
+{
+ virtual int run(int, char*[])
+ {
+ ObjectAdapterPtr adapter = communicator()->createObjectAdapter("fred");
+ adapter->activate();
+
+ IceUtil::Handle<fredHook> hook(new fredHook(adapter));
+
+ // this sample code does not actually locate the target SIP component
+ AuthExtensionPointPrx epPrx = AuthExtensionPointPrx::uncheckedCast(communicator()->stringToProxy("sip_component"));
+ RequestTypeSeq requestTypes;
+ requestTypes.push_back(DialogEstablishing);
+ HookId _hookId = epPrx->addAuthHook(hook->_proxy, requestTypes);
+
+ communicator()->waitForShutdown();
+ epPrx->removeAuthHook(_hookId);
+
+ return 0;
+ }
+};
+
+int main(int argc, char *argv[])
+{
+ fred app;
+ return app.main(argc, argv);
+}
diff --git a/fred.java b/fred.java
index 91e8137..563f2f7 100644
--- a/fred.java
+++ b/fred.java
@@ -10,12 +10,16 @@ public class fred extends Ice.Application
Ice.ObjectAdapter adapter = communicator().createObjectAdapter("fred");
adapter.activate();
fredHook._adapter = adapter;
+
fredHook hook = new fredHook();
+
// this sample code does not actually locate the target SIP component
AuthExtensionPointPrx epPrx = AuthExtensionPointPrxHelper.uncheckedCast(communicator().stringToProxy("sip_component"));
_hookId = epPrx.addAuthHook(hook._proxy, new RequestType[]{ RequestType.DialogEstablishing });
+
communicator().waitForShutdown();
epPrx.removeAuthHook(_hookId);
+
return 0;
}
diff --git a/fred.py b/fred.py
index 044c8d4..b548d05 100644
--- a/fred.py
+++ b/fred.py
@@ -31,12 +31,16 @@ class fred(Ice.Application):
adapter = self.communicator().createObjectAdapter("fred")
adapter.activate()
fredHook._adapter = adapter
+
hook = fredHook()
- # this sample code does not actually locate the target SIP component
+
+ # this sample code does not actually locate the target SIP component
epPrx = AuthExtensionPointPrx.uncheckedCast(communicator().stringToProxy("sip_component"))
_hookId = epPrx.addAuthHook(hook._proxy, [ RequestType.DialogEstablishing ])
+
self.communicator().waitForShutdown()
epPrx.removeAuthHook(_hookId)
+
return 0
app = fred()
diff --git a/fredHook.java b/fredHook.java
index 22b4c65..f0800c5 100644
--- a/fredHook.java
+++ b/fredHook.java
@@ -27,5 +27,4 @@ public class fredHook extends _AuthHookDisp
return result;
}
-
}
commit 57c0bbea56fae6585ecf13f0628f79e437ee9e74
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Sat Feb 5 14:10:31 2011 +0100
Flesh out Python example.
diff --git a/fred.py b/fred.py
index b465b9c..044c8d4 100644
--- a/fred.py
+++ b/fred.py
@@ -3,18 +3,40 @@ from AsteriskSCF.SIP.ExtensionPoint.V1 import *
from AsteriskSCF.System.Hook.V1 import *
class fredHook(AuthHook):
+ _adapter = None
+ _proxy = None
+
+ def __init__(self):
+ _proxy = AuthHookPrx.uncheckedCast(_adapter.addWithUUID(self))
+
def challengeRequest(info, challenges):
result = HookResult()
- result.status = HookStatus.Declined
+ challenge = DigestChallenge()
+
+ challenge.username = "bob"
+ challenge.password = "alice"
+ challenge.domain = [ "example.com" ]
+ challenge.algorithm = DigestAlgorithm.AKAv1MD5
+
+ challenges = [ challenge ]
+
+ result.status = HookStatus.Succeeded
+
return result
class fred(Ice.Application):
+ _hookId = None
+
def run(self, args):
adapter = self.communicator().createObjectAdapter("fred")
adapter.activate()
-# fredHook._adapter = adapter
+ fredHook._adapter = adapter
hook = fredHook()
+ # this sample code does not actually locate the target SIP component
+ epPrx = AuthExtensionPointPrx.uncheckedCast(communicator().stringToProxy("sip_component"))
+ _hookId = epPrx.addAuthHook(hook._proxy, [ RequestType.DialogEstablishing ])
self.communicator().waitForShutdown()
+ epPrx.removeAuthHook(_hookId)
return 0
app = fred()
commit ade824dd35108f0ca494b8deb415924bbf61b522
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Sat Feb 5 11:04:48 2011 +0100
Begin a Python example.
diff --git a/fred.py b/fred.py
new file mode 100644
index 0000000..b465b9c
--- /dev/null
+++ b/fred.py
@@ -0,0 +1,21 @@
+import sys, threading, Ice
+from AsteriskSCF.SIP.ExtensionPoint.V1 import *
+from AsteriskSCF.System.Hook.V1 import *
+
+class fredHook(AuthHook):
+ def challengeRequest(info, challenges):
+ result = HookResult()
+ result.status = HookStatus.Declined
+ return result
+
+class fred(Ice.Application):
+ def run(self, args):
+ adapter = self.communicator().createObjectAdapter("fred")
+ adapter.activate()
+# fredHook._adapter = adapter
+ hook = fredHook()
+ self.communicator().waitForShutdown()
+ return 0
+
+app = fred()
+# sys.exit(app.main(sys.argv))
commit c675d80f600e17744848aadbfe39a4baccc351b9
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Sat Feb 5 11:02:54 2011 +0100
Convert examples to be called 'fred'.
diff --git a/.gitignore b/.gitignore
index 6b468b6..d1c8995 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
*.class
+*.pyc
diff --git a/Makefile b/Makefile
index b845e72..11864ed 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,18 @@
-export CLASSPATH=/home/kpfleming/git/asterisk-scf/fosdem:/home/kpfleming/git/asterisk-scf/gitall/slice/target/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
+export CLASSPATH=/home/kpfleming/git/asterisk-scf/fosdem:/home/kpfleming/git/asterisk-scf/gitall/slice/java/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
+export PYTHONPATH=/opt/Ice-3.4/python:/home/kpfleming/git/asterisk-scf/gitall/slice/python
-all: sip_hook.class
+all: fred.class fred.pyc
-example/HookI.class: example/HookI.java
+fredHook.class: fredHook.java
javac -Xlint:deprecation $<
-sip_hook.class: sip_hook.java example/HookI.class
+fred.class: fred.java fredHook.class
javac -Xlint:deprecation $<
-clean:
- rm -rf sip_hook.class
- rm -rf example/HookI.class
+fred.pyc: fred.py
+ python $<
+clean:
+ rm -rf fred.class
+ rm -rf fredHook.class
+ rm -rf fred.pyc
diff --git a/sip_hook.java b/fred.java
similarity index 76%
rename from sip_hook.java
rename to fred.java
index f08ad41..91e8137 100644
--- a/sip_hook.java
+++ b/fred.java
@@ -1,18 +1,16 @@
-import example.*;
-
import AsteriskSCF.System.Hook.V1.*;
import AsteriskSCF.SIP.ExtensionPoint.V1.*;
-public class sip_hook extends Ice.Application
+public class fred extends Ice.Application
{
private HookId _hookId;
public int run(String[] args)
{
- Ice.ObjectAdapter adapter = communicator().createObjectAdapter("sip_hook");
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("fred");
adapter.activate();
- HookI._adapter = adapter;
- HookI hook = new HookI();
+ fredHook._adapter = adapter;
+ fredHook hook = new fredHook();
// this sample code does not actually locate the target SIP component
AuthExtensionPointPrx epPrx = AuthExtensionPointPrxHelper.uncheckedCast(communicator().stringToProxy("sip_component"));
_hookId = epPrx.addAuthHook(hook._proxy, new RequestType[]{ RequestType.DialogEstablishing });
@@ -23,7 +21,7 @@ public class sip_hook extends Ice.Application
public static void main(String[] args)
{
- sip_hook app = new sip_hook();
- System.exit(app.main("sip_hook", args));
+ fred app = new fred();
+ System.exit(app.main("fred", args));
}
}
diff --git a/example/HookI.java b/fredHook.java
similarity index 90%
rename from example/HookI.java
rename to fredHook.java
index a82cbd3..22b4c65 100644
--- a/example/HookI.java
+++ b/fredHook.java
@@ -1,14 +1,12 @@
-package example;
-
import AsteriskSCF.System.Hook.V1.*;
import AsteriskSCF.SIP.ExtensionPoint.V1.*;
-public class HookI extends _AuthHookDisp
+public class fredHook extends _AuthHookDisp
{
public static Ice.ObjectAdapter _adapter;
public AuthHookPrx _proxy;
- public HookI()
+ public fredHook()
{
_proxy = AuthHookPrxHelper.uncheckedCast(_adapter.addWithUUID(this));
}
commit 0dbd0032333bf8bb8b03f050e522d22166138862
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Feb 4 22:09:59 2011 +0100
Java example is now complete... at least it compiles.
diff --git a/example/HookI.java b/example/HookI.java
index 31ca168..a82cbd3 100644
--- a/example/HookI.java
+++ b/example/HookI.java
@@ -1,28 +1,31 @@
+package example;
+
import AsteriskSCF.System.Hook.V1.*;
import AsteriskSCF.SIP.ExtensionPoint.V1.*;
public class HookI extends _AuthHookDisp
{
public static Ice.ObjectAdapter _adapter;
- private Ice.Identity _id;
+ public AuthHookPrx _proxy;
public HookI()
{
- _id = new Ice.Identity();
- _id.name = Ice.Util.generateUUID();
- _adapter.add(this, _id);
- }
-
- public AuthHookPrx getProxy()
- {
- return AuthHookPrxHelper.uncheckedCast(_adapter.createProxy(_id));
+ _proxy = AuthHookPrxHelper.uncheckedCast(_adapter.addWithUUID(this));
}
public HookResult challengeRequest(RequestInfo info, DigestChallengeSeqHolder challengeSeq, Ice.Current current)
{
HookResult result = new HookResult();
+ DigestChallenge challenge = new DigestChallenge();
+
+ challenge.username = "bob";
+ challenge.password = "alice";
+ challenge.domain = new String[]{ "example.com" };
+ challenge.algorithm = DigestAlgorithm.AKAv1MD5;
+
+ challengeSeq.value = new DigestChallenge[]{ challenge };
- result.status = HookStatus.Declined;
+ result.status = HookStatus.Succeeded;
return result;
}
diff --git a/sip_hook.java b/sip_hook.java
index 62c541e..f08ad41 100644
--- a/sip_hook.java
+++ b/sip_hook.java
@@ -1,13 +1,23 @@
import example.*;
+import AsteriskSCF.System.Hook.V1.*;
+import AsteriskSCF.SIP.ExtensionPoint.V1.*;
+
public class sip_hook extends Ice.Application
{
+ private HookId _hookId;
+
public int run(String[] args)
{
- Ice.ObjectAdapter adapter = communicator().createObjectAdapter("sip-hook");
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("sip_hook");
adapter.activate();
HookI._adapter = adapter;
+ HookI hook = new HookI();
+ // this sample code does not actually locate the target SIP component
+ AuthExtensionPointPrx epPrx = AuthExtensionPointPrxHelper.uncheckedCast(communicator().stringToProxy("sip_component"));
+ _hookId = epPrx.addAuthHook(hook._proxy, new RequestType[]{ RequestType.DialogEstablishing });
communicator().waitForShutdown();
+ epPrx.removeAuthHook(_hookId);
return 0;
}
commit 8bb5ea9643d4e0b46823065f576127cfc6a7ac23
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Feb 4 18:21:28 2011 +0100
work in progress
diff --git a/Makefile b/Makefile
index a2308af..b845e72 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,14 @@
-export CLASSPATH=/home/kpfleming/git/asterisk-scf/gitall/slice/target/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
+export CLASSPATH=/home/kpfleming/git/asterisk-scf/fosdem:/home/kpfleming/git/asterisk-scf/gitall/slice/target/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
all: sip_hook.class
-sip_hook.class: sip_hook.java
- javac $<
+example/HookI.class: example/HookI.java
+ javac -Xlint:deprecation $<
+
+sip_hook.class: sip_hook.java example/HookI.class
+ javac -Xlint:deprecation $<
clean:
rm -rf sip_hook.class
+ rm -rf example/HookI.class
+
diff --git a/example/HookI.java b/example/HookI.java
new file mode 100644
index 0000000..31ca168
--- /dev/null
+++ b/example/HookI.java
@@ -0,0 +1,30 @@
+import AsteriskSCF.System.Hook.V1.*;
+import AsteriskSCF.SIP.ExtensionPoint.V1.*;
+
+public class HookI extends _AuthHookDisp
+{
+ public static Ice.ObjectAdapter _adapter;
+ private Ice.Identity _id;
+
+ public HookI()
+ {
+ _id = new Ice.Identity();
+ _id.name = Ice.Util.generateUUID();
+ _adapter.add(this, _id);
+ }
+
+ public AuthHookPrx getProxy()
+ {
+ return AuthHookPrxHelper.uncheckedCast(_adapter.createProxy(_id));
+ }
+
+ public HookResult challengeRequest(RequestInfo info, DigestChallengeSeqHolder challengeSeq, Ice.Current current)
+ {
+ HookResult result = new HookResult();
+
+ result.status = HookStatus.Declined;
+
+ return result;
+ }
+
+}
diff --git a/sip_hook.java b/sip_hook.java
index fee19ab..62c541e 100644
--- a/sip_hook.java
+++ b/sip_hook.java
@@ -1,4 +1,4 @@
-// import example.*;
+import example.*;
public class sip_hook extends Ice.Application
{
@@ -6,6 +6,7 @@ public class sip_hook extends Ice.Application
{
Ice.ObjectAdapter adapter = communicator().createObjectAdapter("sip-hook");
adapter.activate();
+ HookI._adapter = adapter;
communicator().waitForShutdown();
return 0;
}
commit 51aa937151db2d657eb6fd4d1a87f47652381f5f
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Feb 4 17:38:49 2011 +0100
ignore generated Java class files
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6b468b6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.class
commit 52b6d96a906238928e44b171d7a8701ae448b16d
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Feb 4 17:38:32 2011 +0100
beginning of example code
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..a2308af
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,9 @@
+export CLASSPATH=/home/kpfleming/git/asterisk-scf/gitall/slice/target/asterisk-scf-api.jar:/opt/Ice-3.4/lib/Ice.jar
+
+all: sip_hook.class
+
+sip_hook.class: sip_hook.java
+ javac $<
+
+clean:
+ rm -rf sip_hook.class
diff --git a/sip_hook.java b/sip_hook.java
new file mode 100644
index 0000000..fee19ab
--- /dev/null
+++ b/sip_hook.java
@@ -0,0 +1,18 @@
+// import example.*;
+
+public class sip_hook extends Ice.Application
+{
+ public int run(String[] args)
+ {
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("sip-hook");
+ adapter.activate();
+ communicator().waitForShutdown();
+ return 0;
+ }
+
+ public static void main(String[] args)
+ {
+ sip_hook app = new sip_hook();
+ System.exit(app.main("sip_hook", args));
+ }
+}
-----------------------------------------------------------------------
--
team/dlee/fosdem2011.git
More information about the asterisk-scf-commits
mailing list