From 02239b51f73f2d67370b1a18f0101bcf6fed9a85 Mon Sep 17 00:00:00 2001
From: Guilhem Moulin <guilhem.moulin@fripost.org>
Date: Fri, 11 May 2012 02:29:42 +0200
Subject: Adding colors to the LDAP schema.

---
 figures/ldap.tex | 151 +++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 107 insertions(+), 44 deletions(-)

(limited to 'figures/ldap.tex')

diff --git a/figures/ldap.tex b/figures/ldap.tex
index 123ab83..1d435eb 100644
--- a/figures/ldap.tex
+++ b/figures/ldap.tex
@@ -5,49 +5,73 @@
 \usepackage{array}
 \usepackage{ae}
 \usepackage{tikz}
-\usetikzlibrary{trees,calc,external}
+\usetikzlibrary{trees,fit,shapes,calc,external}
+\tikzset{external/force remake}
 \tikzexternalize
 
 \def\dn#1{\texttt{#1}}
 
-\newenvironment{entry}[1]
-  {\begin{minipage}[t][0pt][t]{10cm}
-     \texttt{#1}
-     \\[.1\baselineskip] \phantom{cn=}%
-     \begin{tabular}[!t]{@{}>{\ttfamily\bgroup}l<{\egroup}@{:~}%
-                            >{\sffamily\bgroup}l<{\egroup}@{}}%
-  }
-  {  \end{tabular}
-   \end{minipage}}
-
-\tikzset{
-  ldaptree/.style = {
-    grow via three points={one child at (1cm,-1.5\baselineskip) and two children at (1cm,-1.5\baselineskip) and (1cm,-3\baselineskip)},
-    growth parent anchor=south west,
-    edge from parent path={($(\tikzparentnode.south west)+(2.5ex,0)$) |- (\tikzchildnode.west)},
-  },
-  every node/.style = {anchor=west},
-  dn/.style = {font=\ttfamily}
+\newenvironment{entry}[1]{%
+  \begin{tabular}[t]{@{}l@{}}
+    \dn{#1}
+    \\[.1\baselineskip] \phantom{cn=}%
+    \begin{tabular}{@{}>{\ttfamily\bgroup}l<{\egroup:}@{~}%
+                       >{\sffamily\bgroup}l<{\egroup}@{}}%
+}{%
+    \end{tabular}
+  \end{tabular}
+}
+
+\tikzstyle{ldaptree} = [%
+  anchor=west,
+  grow via three points={one child at (1cm,-1.5\baselineskip) and two children at (1cm,-1.5\baselineskip) and (1cm,-3\baselineskip)},
+  growth parent anchor=south west,
+  edge from parent path={($(\tikzparentnode.south west)+(2.5ex,0)$) |- (\tikzchildnode.mid west)
+},
+  edge from parent/.style = {draw=black!20}
+]
+
+
+\tikzstyle{entry} = [line width=1pt,dashed,rounded corners]
+\tikzstyle{manager} = [entry,fill=red!30,draw=red]
+\tikzstyle{service} = [entry,fill=blue!30,draw=blue]
+\tikzstyle{vdomain} = [entry,fill=green!30,draw=green]
+\tikzstyle{valias} = [vdomain]
+\tikzstyle{vuser} = [vdomain]
+\tikzstyle{dn} = [font=\ttfamily]
+\tikzstyle{ACL} = [line width=1.5pt,fill=none,solid]
+
+\pgfdeclarelayer{background}
+\pgfdeclarelayer{foreground}
+\pgfsetlayers{background,main,foreground}
+
+
+\def\noSSHA{%
+  \tikz[baseline,anchor=text,inner sep=0,outer sep=0]
+    \node [anchor=text,service,ACL,cross out,draw opacity=.75]
+      {\{SSHA\}xxxxxx};
 }
 
 \thispagestyle{empty}
 \begin{document}
 
-\tikzsetnextfilename{ldap-cropped}
+
+\centering
+\tikzsetnextfilename{ldap-trimmed}
 \begin{tikzpicture}[ldaptree]
   \node[dn] { {o=mailhosting,dc=fripost,dc=org} }
     child {
       node[dn] { ou=managers } 
       child {
-        node {
+        node[manager] (gustav) {
           \begin{entry}{cn=gustav}
             userPassword & \{SSHA\}xxxxxx
           \end{entry}
         }
       } 
       child [missing] {}
-      child[dn] {
-        node {
+      child {
+        node[manager] (ljo) {
           \begin{entry}{cn=ljo}
             userPassword & \dots
           \end{entry}
@@ -61,7 +85,7 @@
     child {
       node[dn] { ou=services } 
       child {
-        node {
+        node[service] (SMTP) {
           \begin{entry}{cn=SMTP}
             userPassword & \{SSHA\}xxxxxx
           \end{entry}
@@ -69,7 +93,7 @@
       } 
       child [missing] {}
       child {
-        node {
+        node[service] (SASLauth) {
           \begin{entry}{cn=SASLauth}
             userPassword & \dots
           \end{entry}
@@ -81,17 +105,16 @@
     child [missing] {}
     child [missing] {}
     child {
-      node[dn] { ou=virtual }
+      node[dn] (virtual) { ou=virtual }
       child {
-        node {
+        node[vdomain] {
           \begin{entry}{dc=fripost.org}
             isActive & TRUE
           \end{entry}
-        }
-        child [missing] {}
-        child 
+        } [every child node/.style={yshift=-\baselineskip}]
+        child
         {
-          node {
+          node[valias] {
             \begin{entry}{mailTarget=user@fripost.org}
               mailLocalAddress & user-alias \\
               isActive & TRUE 
@@ -99,23 +122,22 @@
           }
         }
         child [missing] {}
-        child [missing] {}
         child 
-        { node { \dn{mailTarget=\dots} } 
+        { node[valias] { \dn{mailTarget=\dots} } 
         }
+        child [missing] {}
         child 
         {
-          node {
+          node[vuser] (user-fripost-org) {
             \begin{entry}{uid=user}
-              userPassword & \{SSHA\}xxxxxx \\
+              userPassword & \noSSHA \\
               isactive & TRUE 
             \end{entry}
           }
         }
         child [missing] {}
-        child [missing] {}
         child 
-        { node { \dn{uid=\dots} } 
+        { node[vuser] { \dn{uid=\dots} } 
         }
       }
       child [missing] {}
@@ -129,16 +151,15 @@
       child [missing] {}
       child [missing] {}
       child {
-        node {
+        node[vdomain] (example-org) {
           \begin{entry}{dc=example.org}
             owner & \texttt{uid=user,dc=fripost.org,ou=virtual,\dots} \\
             isActive & TRUE
           \end{entry}
-        }
-        child [missing] {}
+        } [every child node/.style={yshift=-\baselineskip}]
         child 
           {
-          node {
+          node[valias] {
             \begin{entry}{mailTarget=user@fripost.org}
               mailLocalAddress & user \\
               isActive & TRUE
@@ -146,15 +167,57 @@
           }
         }
         child [missing] {}
-        child [missing] {}
         child 
-        { node { \dn{mailTarget=\dots} } 
+        { node[valias] { \dn{mailTarget=\dots} } 
         }
         child 
-        { node { \dn{uid=\dots} } 
+        { node[vuser] (example-org-uid-etc) { \dn{uid=\dots} } 
         }
       }
     };
+
+\begin{pgfonlayer}{background}
+  \node[fit=(example-org)(example-org-uid-etc),inner sep=3pt,
+        fill=yellow!50, opacity=.3, rounded corners, draw, dashed]
+    (example-org-fit) {};
+
+  \node[fit=(virtual)(example-org-fit),inner sep=3pt,
+        fill=yellow!50, opacity=.3, rounded corners, draw, dashed]
+    (virtual-fit) {};
+\end{pgfonlayer}
+\tikzset{trim left=0,trim right=(virtual-fit.east)}
+
+\draw[->,manager,ACL]
+    (gustav.north east)
+    .. controls +(0:5cm) and +(45:4cm) ..
+    (virtual-fit.north east)
+    node[pos=.3,above,sloped] {read, write};
+\draw[->,manager,ACL]
+    (ljo.north east)
+    .. controls +(0:5cm) and +(45:4cm) ..
+    (virtual-fit.north east);
+
+\draw[->,vuser,ACL]
+    (user-fripost-org.north east)
+    .. controls +(45:3cm) and +(45:3cm) ..
+    (example-org-fit.north east)
+    node[pos=.5,above,sloped] {read, write};
+
+\draw[->,vuser,ACL]
+    (user-fripost-org.north west)
+    .. controls +(135:1cm) and +(180:3cm) ..
+    ($(user-fripost-org.mid west)+(2em,-\baselineskip)$)
+    node[pos=.5,above,sloped] {write};
+
+\draw[->,service,ACL]
+    (SMTP.north west)
+    .. controls +(180:6cm) and +(180:5cm) ..
+    (virtual-fit.west)
+    node[pos=.45,above,sloped] {read};
+\draw[->,service,ACL]
+    (SASLauth.north west)
+    .. controls +(180:5cm) and +(180:4cm) ..
+    (virtual-fit.west);
 \end{tikzpicture}
 
 \end{document}
-- 
cgit v1.2.3

