directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject [11/48] directory-kerby git commit: DIRKRB-421. Define transaction API for identity backend
Date Wed, 04 Nov 2015 08:25:37 GMT
DIRKRB-421. Define transaction API for identity backend


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

Branch: refs/heads/pkinit-support
Commit: 0aa0802bd36f1359d3eef1317221201697bec821
Parents: 6e15b50
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Thu Sep 24 22:10:44 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Thu Sep 24 22:10:44 2015 +0800

----------------------------------------------------------------------
 .../kerb/identity/CacheableIdentityService.java | 16 +++++
 .../kerberos/kerb/identity/IdentityService.java | 12 ++++
 .../kerb/identity/IdentityTransaction.java      | 64 ++++++++++++++++++++
 .../backend/AbstractIdentityBackend.java        | 17 ++++++
 4 files changed, 109 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0aa0802b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/CacheableIdentityService.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/CacheableIdentityService.java
b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/CacheableIdentityService.java
index f53220c..5b9ec29 100644
--- a/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/CacheableIdentityService.java
+++ b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/CacheableIdentityService.java
@@ -50,6 +50,22 @@ public class CacheableIdentityService
         init();
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean supportTransaction() {
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IdentityTransaction startTransaction() throws KrbException {
+        throw new KrbException("Transaction isn't supported");
+    }
+
     private void init() {
         Map<String, KrbIdentity> tmpMap =
             new LinkedHashMap<String, KrbIdentity>(cacheSize) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0aa0802b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityService.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityService.java
b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityService.java
index 3d2e7dd..73ff44b 100644
--- a/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityService.java
+++ b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityService.java
@@ -27,6 +27,18 @@ import org.apache.kerby.kerberos.kerb.KrbException;
 public interface IdentityService {
 
     /**
+     * Query to know if transaction is supported or not.
+     * @return true if supported, false otherwise
+     */
+    boolean supportTransaction();
+
+    /**
+     * Start a transaction.
+     * @return transaction
+     */
+    IdentityTransaction startTransaction() throws KrbException;
+
+    /**
      * Get all of the identity principal names.
      * Note it's ordered by principal name.
      * @return principal names

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0aa0802b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityTransaction.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityTransaction.java
b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityTransaction.java
new file mode 100644
index 0000000..d86876b
--- /dev/null
+++ b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/IdentityTransaction.java
@@ -0,0 +1,64 @@
+/**
+ *  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;
+
+import org.apache.kerby.kerberos.kerb.KrbException;
+
+/**
+ * Identity transaction for KDC backend to create/update/delete principal accounts.
+ */
+public interface IdentityTransaction {
+
+    /**
+     * Commit this transaction, releasing any associated resources.
+     * @throws KrbException
+     */
+    void commit() throws KrbException;
+
+    /**
+     * Give up this transaction, releasing any associated resources.
+     * @throws KrbException
+     */
+    void rollback() throws KrbException;
+
+    /**
+     * Add an identity, and return the newly created result.
+     * @param identity The identity
+     * @return IdentityTransaction
+     * @throws KrbException e
+     */
+    IdentityTransaction addIdentity(KrbIdentity identity) throws KrbException;
+
+    /**
+     * Update an identity, and return the updated result.
+     * @param identity The identity
+     * @return IdentityTransaction
+     * @throws KrbException e
+     */
+    IdentityTransaction updateIdentity(KrbIdentity identity) throws KrbException;
+
+    /**
+     * Delete the identity specified by principal name
+     * @param principalName The principal name
+     * @return IdentityTransaction
+     * @throws KrbException e
+     */
+    IdentityTransaction deleteIdentity(String principalName) throws KrbException;
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0aa0802b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/AbstractIdentityBackend.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/AbstractIdentityBackend.java
b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/AbstractIdentityBackend.java
index 774ee6d..a63e054 100644
--- a/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/AbstractIdentityBackend.java
+++ b/kerby-kerb/kerb-identity/src/main/java/org/apache/kerby/kerberos/kerb/identity/backend/AbstractIdentityBackend.java
@@ -21,6 +21,7 @@ package org.apache.kerby.kerberos.kerb.identity.backend;
 
 import org.apache.kerby.config.Configured;
 import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.identity.IdentityTransaction;
 import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -56,6 +57,22 @@ public abstract class AbstractIdentityBackend
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean supportTransaction() {
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IdentityTransaction startTransaction() throws KrbException {
+        throw new KrbException("Transaction isn't supported");
+    }
+
+    /**
      * Perform the real initialization work for the backend.
      * @throws KrbException e
      */


Mime
View raw message