Hello Kai,

On Sat, Mar 14, 2015 at 10:54 AM, <[email protected]> wrote:

> Repository: directory-kerberos
> Updated Branches:
>   refs/heads/master 1abc0cd9a -> 097d43c42
>
>
> Working on json file based backend
>
>
> Project: http://git-wip-us.apache.org/repos/asf/directory-kerberos/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/directory-kerberos/commit/4f544720
> Tree:
> http://git-wip-us.apache.org/repos/asf/directory-kerberos/tree/4f544720
> Diff:
> http://git-wip-us.apache.org/repos/asf/directory-kerberos/diff/4f544720
>
> Branch: refs/heads/master
> Commit: 4f544720948db5a5cc369c7ea97de139513b8bc9
> Parents: a94dd21
> Author: Drankye <[email protected]>
> Authored: Fri Mar 13 06:00:46 2015 +0800
> Committer: Drankye <[email protected]>
> Committed: Fri Mar 13 06:00:46 2015 +0800
>
> ----------------------------------------------------------------------
>  kdc-backend/Json-identity-backend/pom.xml       |  46 +++++++++
>  .../identitybackend/JsonIdentityBackend.java    | 103 +++++++++++++++++++
>  kdc-backend/pom.xml                             |   1 +
>  3 files changed, 150 insertions(+)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/4f544720/kdc-backend/Json-identity-backend/pom.xml
> ----------------------------------------------------------------------
> diff --git a/kdc-backend/Json-identity-backend/pom.xml
> b/kdc-backend/Json-identity-backend/pom.xml
> new file mode 100644
> index 0000000..d233d9c
> --- /dev/null
> +++ b/kdc-backend/Json-identity-backend/pom.xml
> @@ -0,0 +1,46 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> +  Licensed 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. See accompanying LICENSE file.
> +-->
> +<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/maven-v4_0_0.xsd
> ">
> +  <modelVersion>4.0.0</modelVersion>
> +
> +  <parent>
> +    <groupId>org.apache.kerby</groupId>
> +    <artifactId>kdc-backend</artifactId>
> +    <version>1.0-SNAPSHOT</version>
> +  </parent>
> +
> +  <artifactId>Json-identity-backend</artifactId>
> +
> +  <name>Json identity backend</name>
> +  <description>Json identity backend</description>
> +
> +  <dependencies>
> +    <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>com.googlecode.json-simple</groupId>
>
I have been using google-gson[1] and it served as a great library for many
of my usecases
and is used in eSCIMo too.

just wanted to let you know about this alternative, in case if you want to
consider.

[1] https://code.google.com/p/google-gson/

+      <artifactId>json-simple</artifactId>
> +      <version>1.1.1</version>
> +    </dependency>
> +  </dependencies>
> +</project>
>
>
> http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/4f544720/kdc-backend/Json-identity-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/JsonIdentityBackend.java
> ----------------------------------------------------------------------
> diff --git
> a/kdc-backend/Json-identity-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/JsonIdentityBackend.java
> b/kdc-backend/Json-identity-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/JsonIdentityBackend.java
> new file mode 100644
> index 0000000..a54ca08
> --- /dev/null
> +++
> b/kdc-backend/Json-identity-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/JsonIdentityBackend.java
> @@ -0,0 +1,103 @@
> +/**
> + *  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.kdc.identitybackend;
> +
> +import org.apache.kerby.config.Config;
> +import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
> +import
> org.apache.kerby.kerberos.kerb.identity.backend.InMemoryIdentityBackend;
> +
> +import java.io.File;
> +import java.io.FileNotFoundException;
> +import java.io.IOException;
> +
> +/**
> + * An LDAP based backend implementation.
> + *
> + */
> +public class JsonIdentityBackend extends InMemoryIdentityBackend {
> +    public static final String JSON_IDENTITY_BACKEND_FILE =
> +            "kdc.identitybackend.json.file";
> +    private Config config;
> +    private File jsonKdbFile;
> +
> +    /**
> +     * Constructing an instance using specified config that contains
> anything
> +     * to be used to initialize the json format database.
> +     * @param config
> +     */
> +    public JsonIdentityBackend(Config config) {
> +        this.config = config;
> +    }
> +
> +    /**
> +     * Load identities from file
> +     */
> +    public void load() throws IOException {
> +        String jsonFile = config.getString(JSON_IDENTITY_BACKEND_FILE);
> +        if (jsonFile == null || jsonFile.isEmpty()) {
> +            throw new RuntimeException("No json kdb file is found");
> +        }
> +
> +        jsonKdbFile = new File(jsonFile);
> +        if (! jsonKdbFile.exists()) {
> +            throw new FileNotFoundException("File not found:" + jsonFile);
> +        }
> +
> +        // TODO: load the kdb file.
> +    }
> +
> +    private void checkAndLoad() {
> +        // TODO: check kdb file timestamp to see if it's changed or not.
> If
> +        // necessary load the kdb again.
> +    }
> +
> +    /**
> +     * Persist the updated identities back
> +     */
> +    public void save() {
> +        // TODO: save into the kdb file
> +    }
> +
> +    @Override
> +    public KrbIdentity getIdentity(String name) {
> +        return super.getIdentity(name);
> +    }
> +
> +    @Override
> +    public void addIdentity(KrbIdentity identity) {
> +        super.addIdentity(identity);
> +
> +        // TODO: save
> +    }
> +
> +    @Override
> +    public void updateIdentity(KrbIdentity identity) {
> +        super.updateIdentity(identity);
> +
> +        // TODO: save
> +    }
> +
> +    @Override
> +    public void deleteIdentity(KrbIdentity identity) {
> +        super.deleteIdentity(identity);
> +
> +        // TODO: save
> +    }
> +}
>
>
> http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/4f544720/kdc-backend/pom.xml
> ----------------------------------------------------------------------
> diff --git a/kdc-backend/pom.xml b/kdc-backend/pom.xml
> index 8f81d7b..66408b2 100644
> --- a/kdc-backend/pom.xml
> +++ b/kdc-backend/pom.xml
> @@ -28,5 +28,6 @@
>
>    <modules>
>      <module>ldap-identity-backend</module>
> +    <module>json-identity-backend</module>
>    </modules>
>  </project>
>
>


-- 
Kiran Ayyagari
http://keydap.com

Reply via email to