directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject directory-kerby git commit: first drop of mavibot backend (work in progress)
Date Wed, 01 Jul 2015 13:17:14 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master cdfbc825f -> 59b004264


first drop of mavibot backend (work in progress)


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/59b00426
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/59b00426
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/59b00426

Branch: refs/heads/master
Commit: 59b0042648f391e2c2a97d7028b1175750a646b3
Parents: cdfbc82
Author: Kiran Ayyagari <kayyagari@apache.org>
Authored: Wed Jul 1 21:16:25 2015 +0800
Committer: Kiran Ayyagari <kayyagari@apache.org>
Committed: Wed Jul 1 21:16:25 2015 +0800

----------------------------------------------------------------------
 kerby-backend/mavibot/pom.xml                   |  46 +++++++
 .../org/apache/kerby/KrbIdentityComparator.java |  43 ++++++
 .../org/apache/kerby/KrbIdentitySerializer.java |  83 +++++++++++
 .../java/org/apache/kerby/MavibotBackend.java   | 137 +++++++++++++++++++
 4 files changed, 309 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/59b00426/kerby-backend/mavibot/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-backend/mavibot/pom.xml b/kerby-backend/mavibot/pom.xml
new file mode 100644
index 0000000..cc5dfa8
--- /dev/null
+++ b/kerby-backend/mavibot/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.kerby</groupId>
+    <artifactId>kerby-backend</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>mavibot-backend</artifactId>
+  <name>Mavibot based backend</name>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.directory.mavibot</groupId>
+      <artifactId>mavibot</artifactId>
+      <version>1.0.0-M8-SNAPSHOT</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerby-config</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerb-identity</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerb-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerb-identity-test</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/59b00426/kerby-backend/mavibot/src/main/java/org/apache/kerby/KrbIdentityComparator.java
----------------------------------------------------------------------
diff --git a/kerby-backend/mavibot/src/main/java/org/apache/kerby/KrbIdentityComparator.java
b/kerby-backend/mavibot/src/main/java/org/apache/kerby/KrbIdentityComparator.java
new file mode 100644
index 0000000..665e30a
--- /dev/null
+++ b/kerby-backend/mavibot/src/main/java/org/apache/kerby/KrbIdentityComparator.java
@@ -0,0 +1,43 @@
+/*
+ *   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;
+
+import java.util.Comparator;
+
+import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
+
+/**
+ * Comparator for KrbIdentity
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class KrbIdentityComparator implements Comparator<KrbIdentity> {
+
+    public static KrbIdentityComparator INSTANCE = new KrbIdentityComparator();
+
+    private KrbIdentityComparator() {
+    }
+
+    @Override
+    public int compare(KrbIdentity o1, KrbIdentity o2) {
+	return o1.getPrincipalName().compareTo(o2.getPrincipalName());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/59b00426/kerby-backend/mavibot/src/main/java/org/apache/kerby/KrbIdentitySerializer.java
----------------------------------------------------------------------
diff --git a/kerby-backend/mavibot/src/main/java/org/apache/kerby/KrbIdentitySerializer.java
b/kerby-backend/mavibot/src/main/java/org/apache/kerby/KrbIdentitySerializer.java
new file mode 100644
index 0000000..2bba2a5
--- /dev/null
+++ b/kerby-backend/mavibot/src/main/java/org/apache/kerby/KrbIdentitySerializer.java
@@ -0,0 +1,83 @@
+/*
+ *   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;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Comparator;
+
+import org.apache.directory.mavibot.btree.serializer.BufferHandler;
+import org.apache.directory.mavibot.btree.serializer.ElementSerializer;
+import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
+
+/**
+ * Serializer class for KrbIdentity.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class KrbIdentitySerializer implements ElementSerializer<KrbIdentity> {
+    /** the static instance of the serializer */
+    public static final KrbIdentitySerializer INSTANCE = new KrbIdentitySerializer();
+
+    /** comparator for KrbIdentity */
+    private KrbIdentityComparator comparator = KrbIdentityComparator.INSTANCE;
+
+    @Override
+    public byte[] serialize(KrbIdentity key) {
+	return null;
+    }
+
+    @Override
+    public KrbIdentity deserialize(BufferHandler bufferHandler)
+	    throws IOException {
+	return null;
+    }
+
+    @Override
+    public KrbIdentity deserialize(ByteBuffer buffer) throws IOException {
+	return null;
+    }
+
+    @Override
+    public KrbIdentity fromBytes(byte[] buffer) throws IOException {
+	return null;
+    }
+
+    @Override
+    public KrbIdentity fromBytes(byte[] buffer, int pos) throws IOException {
+	return null;
+    }
+
+    @Override
+    public int compare(KrbIdentity type1, KrbIdentity type2) {
+	return comparator.compare(type1, type2);
+    }
+
+    @Override
+    public Comparator<KrbIdentity> getComparator() {
+	return comparator;
+    }
+
+    @Override
+    public Class<?> getType() {
+	return KrbIdentity.class;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/59b00426/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java
----------------------------------------------------------------------
diff --git a/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java b/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java
new file mode 100644
index 0000000..7f78866
--- /dev/null
+++ b/kerby-backend/mavibot/src/main/java/org/apache/kerby/MavibotBackend.java
@@ -0,0 +1,137 @@
+/*
+ *   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;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.directory.mavibot.btree.BTree;
+import org.apache.directory.mavibot.btree.BTreeFactory;
+import org.apache.directory.mavibot.btree.BTreeTypeEnum;
+import org.apache.directory.mavibot.btree.PersistedBTreeConfiguration;
+import org.apache.directory.mavibot.btree.RecordManager;
+import org.apache.directory.mavibot.btree.serializer.StringSerializer;
+import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
+import org.apache.kerby.kerberos.kerb.identity.backend.AbstractIdentityBackend;
+
+/**
+ * A backend based on Apache Mavibot(an MVCC BTree library).
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class MavibotBackend extends AbstractIdentityBackend {
+    /** the RecordManager of Mavibot */
+    private RecordManager rm;
+
+    /** the BTree holding all data */
+    private BTree<String, KrbIdentity> database;
+
+    /** name of the database */
+    private static final String DATA_TREE = "kerby-data";
+
+    /** name of the database file */
+    private static final String DATABASE_NAME = "kerby-data.db";
+
+    /**
+     * Creates a new instance of MavibotBackend.
+     *
+     * @param location
+     *            the File handle pointing to the database file or the directory
+     *            where it is present
+     * @throws Exception
+     */
+    public MavibotBackend(File location) throws Exception {
+	String dbPath = location.getAbsolutePath();
+
+	if (!location.exists()) {
+	    location.mkdirs();
+	}
+
+	if (location.isDirectory()) {
+	    dbPath += File.separator + DATABASE_NAME;
+	}
+
+	rm = new RecordManager(dbPath);
+
+	if (rm.getManagedTrees().contains(DATA_TREE)) {
+	    database = rm.getManagedTree(DATA_TREE);
+	} else {
+	    PersistedBTreeConfiguration<String, KrbIdentity> config = new PersistedBTreeConfiguration<String,
KrbIdentity>();
+	    // _no_ duplicates
+	    config.setAllowDuplicates(false);
+	    config.setBtreeType(BTreeTypeEnum.PERSISTED);
+	    config.setFilePath(dbPath);
+	    config.setKeySerializer(StringSerializer.INSTANCE);
+	    config.setName(DATA_TREE);
+	    config.setValueSerializer(KrbIdentitySerializer.INSTANCE);
+
+	    database = BTreeFactory.createPersistedBTree(config);
+	    rm.manage(database);
+	  }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<String> getIdentities(int start, int limit) {
+	return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<String> getIdentities() {
+	return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected KrbIdentity doGetIdentity(String principalName) {
+	return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected KrbIdentity doAddIdentity(KrbIdentity identity) {
+	return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected KrbIdentity doUpdateIdentity(KrbIdentity identity) {
+	return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void doDeleteIdentity(String principalName) {
+
+    }
+}


Mime
View raw message