1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.kerberos.shared.store;
21
22
23 import org.apache.directory.server.core.CoreSession;
24 import org.apache.directory.server.core.DirectoryService;
25 import org.apache.directory.server.kerberos.shared.store.operations.AddPrincipal;
26 import org.apache.directory.server.kerberos.shared.store.operations.ChangePassword;
27 import org.apache.directory.server.kerberos.shared.store.operations.DeletePrincipal;
28 import org.apache.directory.server.kerberos.shared.store.operations.GetAllPrincipals;
29 import org.apache.directory.server.kerberos.shared.store.operations.GetPrincipal;
30 import org.apache.directory.server.protocol.shared.ServiceConfigurationException;
31
32 import javax.security.auth.kerberos.KerberosPrincipal;
33
34
35
36
37
38
39
40
41
42 class SingleBaseSearch implements PrincipalStore
43 {
44 private final CoreSession session;
45
46
47 SingleBaseSearch( DirectoryService directoryService )
48 {
49 try
50 {
51 session = directoryService.getSession();
52 }
53 catch ( Exception e )
54 {
55 throw new ServiceConfigurationException("Can't get a session", e);
56 }
57
58 }
59
60
61 public String addPrincipal( PrincipalStoreEntry entry ) throws Exception
62 {
63 return ( String ) new AddPrincipal( entry ).execute( session, null );
64 }
65
66
67 public String deletePrincipal( KerberosPrincipal principal ) throws Exception
68 {
69 return ( String ) new DeletePrincipal( principal ).execute( session, null );
70 }
71
72
73 public PrincipalStoreEntry[] getAllPrincipals( String realm ) throws Exception
74 {
75 return ( PrincipalStoreEntry[] ) new GetAllPrincipals().execute( session, null );
76 }
77
78
79 public PrincipalStoreEntry getPrincipal( KerberosPrincipal principal ) throws Exception
80 {
81 return ( PrincipalStoreEntry ) new GetPrincipal( principal ).execute( session, null );
82 }
83
84
85 public String changePassword( KerberosPrincipal principal, String newPassword ) throws Exception
86 {
87 return ( String ) new ChangePassword( principal, newPassword ).execute( session, null );
88 }
89 }