directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [1/2] directory-kerby git commit: Initially working on flatbuffers backend
Date Tue, 22 Sep 2015 13:11:42 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/flatbuffers-backend [created] 94e3f8095


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/94e3f809/kerby-backend/flatbuffers-backend/src/test/java/MyGame/Example/TestSimpleTableWithEnum.java
----------------------------------------------------------------------
diff --git a/kerby-backend/flatbuffers-backend/src/test/java/MyGame/Example/TestSimpleTableWithEnum.java
b/kerby-backend/flatbuffers-backend/src/test/java/MyGame/Example/TestSimpleTableWithEnum.java
new file mode 100644
index 0000000..3000cab
--- /dev/null
+++ b/kerby-backend/flatbuffers-backend/src/test/java/MyGame/Example/TestSimpleTableWithEnum.java
@@ -0,0 +1,33 @@
+// automatically generated, do not modify
+
+package MyGame.Example;
+
+import java.nio.*;
+import java.lang.*;
+import java.util.*;
+import com.google.flatbuffers.*;
+
+@SuppressWarnings("unused")
+public final class TestSimpleTableWithEnum extends Table {
+  public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb)
{ return getRootAsTestSimpleTableWithEnum(_bb, new TestSimpleTableWithEnum()); }
+  public static TestSimpleTableWithEnum getRootAsTestSimpleTableWithEnum(ByteBuffer _bb,
TestSimpleTableWithEnum obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__init(_bb.getInt(_bb.position())
+ _bb.position(), _bb)); }
+  public TestSimpleTableWithEnum __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb;
return this; }
+
+  public byte color() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 2; }
+  public boolean mutateColor(byte color) { int o = __offset(4); if (o != 0) { bb.put(o +
bb_pos, color); return true; } else { return false; } }
+
+  public static int createTestSimpleTableWithEnum(FlatBufferBuilder builder,
+      byte color) {
+    builder.startObject(1);
+    TestSimpleTableWithEnum.addColor(builder, color);
+    return TestSimpleTableWithEnum.endTestSimpleTableWithEnum(builder);
+  }
+
+  public static void startTestSimpleTableWithEnum(FlatBufferBuilder builder) { builder.startObject(1);
}
+  public static void addColor(FlatBufferBuilder builder, byte color) { builder.addByte(0,
color, 2); }
+  public static int endTestSimpleTableWithEnum(FlatBufferBuilder builder) {
+    int o = builder.endObject();
+    return o;
+  }
+};
+

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/94e3f809/kerby-backend/flatbuffers-backend/src/test/java/MyGame/Example/Vec3.java
----------------------------------------------------------------------
diff --git a/kerby-backend/flatbuffers-backend/src/test/java/MyGame/Example/Vec3.java b/kerby-backend/flatbuffers-backend/src/test/java/MyGame/Example/Vec3.java
new file mode 100644
index 0000000..86edb6d
--- /dev/null
+++ b/kerby-backend/flatbuffers-backend/src/test/java/MyGame/Example/Vec3.java
@@ -0,0 +1,44 @@
+// automatically generated, do not modify
+
+package MyGame.Example;
+
+import java.nio.*;
+import java.lang.*;
+import java.util.*;
+import com.google.flatbuffers.*;
+
+@SuppressWarnings("unused")
+public final class Vec3 extends Struct {
+  public Vec3 __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; return this; }
+
+  public float x() { return bb.getFloat(bb_pos + 0); }
+  public void mutateX(float x) { bb.putFloat(bb_pos + 0, x); }
+  public float y() { return bb.getFloat(bb_pos + 4); }
+  public void mutateY(float y) { bb.putFloat(bb_pos + 4, y); }
+  public float z() { return bb.getFloat(bb_pos + 8); }
+  public void mutateZ(float z) { bb.putFloat(bb_pos + 8, z); }
+  public double test1() { return bb.getDouble(bb_pos + 16); }
+  public void mutateTest1(double test1) { bb.putDouble(bb_pos + 16, test1); }
+  public byte test2() { return bb.get(bb_pos + 24); }
+  public void mutateTest2(byte test2) { bb.put(bb_pos + 24, test2); }
+  public Test test3() { return test3(new Test()); }
+  public Test test3(Test obj) { return obj.__init(bb_pos + 26, bb); }
+
+  public static int createVec3(FlatBufferBuilder builder, float x, float y, float z, double
test1, byte test2, short test3_a, byte test3_b) {
+    builder.prep(16, 32);
+    builder.pad(2);
+    builder.prep(2, 4);
+    builder.pad(1);
+    builder.putByte(test3_b);
+    builder.putShort(test3_a);
+    builder.pad(1);
+    builder.putByte(test2);
+    builder.putDouble(test1);
+    builder.pad(4);
+    builder.putFloat(z);
+    builder.putFloat(y);
+    builder.putFloat(x);
+    return builder.offset();
+  }
+};
+

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/94e3f809/kerby-backend/flatbuffers-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/FlatbuffersBackendTest.java
----------------------------------------------------------------------
diff --git a/kerby-backend/flatbuffers-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/FlatbuffersBackendTest.java
b/kerby-backend/flatbuffers-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/FlatbuffersBackendTest.java
new file mode 100644
index 0000000..aa3b4eb
--- /dev/null
+++ b/kerby-backend/flatbuffers-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/FlatbuffersBackendTest.java
@@ -0,0 +1,56 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.kerby.kerberos.kerb.identity.backend;
+
+import org.apache.kerby.config.Conf;
+import org.apache.kerby.config.Config;
+import org.apache.kerby.kerberos.kdc.identitybackend.FlatbuffersIdentityBackend;
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import java.io.File;
+
+/**
+ * Flatbuffers backend test
+ */
+public class FlatbuffersBackendTest extends BackendTestBase {
+    private static File fbsBackendFile;
+
+    @BeforeClass
+    public static void setup() throws KrbException {
+        File testDir = new File(System.getProperty("test.dir", "target"));
+        fbsBackendFile = new File(testDir, "fbs-identity-backend-file");
+        String jsonBackendFileString = fbsBackendFile.getAbsolutePath();
+
+        Config backendConfig = new Conf();
+        backendConfig.setString(FlatbuffersIdentityBackend.FBS_IDENTITY_BACKEND_DIR,
+                jsonBackendFileString);
+        backend = new FlatbuffersIdentityBackend(backendConfig);
+        backend.initialize();
+    }
+
+    @AfterClass
+    public static void cleanJsonBackendFile() {
+        if (fbsBackendFile.exists()) {
+            fbsBackendFile.delete();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/94e3f809/kerby-backend/flatbuffers-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/FlatbuffersBackendTestUtil.java
----------------------------------------------------------------------
diff --git a/kerby-backend/flatbuffers-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/FlatbuffersBackendTestUtil.java
b/kerby-backend/flatbuffers-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/FlatbuffersBackendTestUtil.java
new file mode 100644
index 0000000..8061ae5
--- /dev/null
+++ b/kerby-backend/flatbuffers-backend/src/test/java/org/apache/kerby/kerberos/kerb/identity/backend/FlatbuffersBackendTestUtil.java
@@ -0,0 +1,77 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *
+ */
+package org.apache.kerby.kerberos.kerb.identity.backend;
+
+import MyGame.Example.*;
+import com.google.flatbuffers.FlatBufferBuilder;
+import org.apache.kerby.kerberos.kdc.identitybackend.FbsEncryptionKey;
+import org.apache.kerby.kerberos.kdc.identitybackend.FbsKerby;
+import org.apache.kerby.kerberos.kdc.identitybackend.FbsKrbIdentity;
+import org.apache.kerby.kerberos.kdc.identitybackend.FbsPrincipalName;
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
+import org.apache.kerby.kerberos.kerb.spec.base.EncryptionKey;
+import org.apache.kerby.kerberos.kerb.spec.base.PrincipalName;
+
+import java.io.DataOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.List;
+
+/**
+ * Flatbuffers test utilities
+ */
+public class FlatbuffersBackendTestUtil {
+
+    public static void main(String[] args) throws KrbException {
+        List<KrbIdentity> idendenties = BackendTestUtil.createManyIdentities(2);
+
+        FlatBufferBuilder fbb = new FlatBufferBuilder(1024);
+
+        int name = fbb.createString("KerbyBackend");
+
+        KrbIdentity krbId = idendenties.get(0);
+        int princNameOff = fbb.createString(krbId.getPrincipalName());
+        int nameType = krbId.getPrincipal().getNameType().getValue();
+        int princOff = FbsPrincipalName.createFbsPrincipalName(fbb, nameType, princNameOff);
+        EncryptionKey encKey = krbId.getKeys().entrySet().iterator().next().getValue();
+        int keyValueOff = FbsEncryptionKey.createKeyValueVector(fbb, encKey.getKeyData());
+        int encKeyOff = FbsEncryptionKey.createFbsEncryptionKey(fbb,
+                encKey.getKeyType().getValue(), keyValueOff);
+        int keysOff = FbsKrbIdentity.createKeysVector(fbb, new int[]{encKeyOff});
+        int identityOff = FbsKrbIdentity.createFbsKrbIdentity(fbb, princOff, 1, 1, false,
keysOff);
+        int idsOff = FbsKerby.createIdentitiesVector(fbb, new int[]{identityOff});
+
+        FbsKerby.startFbsKerby(fbb);
+        FbsKerby.addName(fbb, name);
+        FbsKerby.addIdentities(fbb, idsOff);
+        int kerbyOff = FbsKerby.endFbsKerby(fbb);
+        FbsKerby.finishFbsKerbyBuffer(fbb, kerbyOff);
+
+        ByteBuffer dataBuffer = fbb.dataBuffer().duplicate();
+
+        FbsKerby fbsKerby2 = FbsKerby.getRootAsFbsKerby(dataBuffer);
+        String kerbyName = fbsKerby2.name();
+        FbsKrbIdentity krbId2 = fbsKerby2.identities(0);
+        String princName2 = krbId2.principal().nameString();
+        return;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/94e3f809/kerby-backend/flatbuffers-backend/src/test/monsterdata_test.mon
----------------------------------------------------------------------
diff --git a/kerby-backend/flatbuffers-backend/src/test/monsterdata_test.mon b/kerby-backend/flatbuffers-backend/src/test/monsterdata_test.mon
new file mode 100644
index 0000000..0505aee
Binary files /dev/null and b/kerby-backend/flatbuffers-backend/src/test/monsterdata_test.mon
differ

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/94e3f809/kerby-backend/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-backend/pom.xml b/kerby-backend/pom.xml
index 1305721..d49f40b 100644
--- a/kerby-backend/pom.xml
+++ b/kerby-backend/pom.xml
@@ -30,6 +30,7 @@
     <module>mavibot-backend</module>
     <module>json-backend</module>
     <module>zookeeper-backend</module>
+    <module>flatbuffers-backend</module>
   </modules>
 
   <dependencies>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/94e3f809/monsterdata_java_wire.mon
----------------------------------------------------------------------
diff --git a/monsterdata_java_wire.mon b/monsterdata_java_wire.mon
new file mode 100644
index 0000000..24602bc
Binary files /dev/null and b/monsterdata_java_wire.mon differ


Mime
View raw message