001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.kerberos.shared.store;
021
022
023 import javax.security.auth.kerberos.KerberosPrincipal;
024
025 import org.apache.directory.server.core.DirectoryService;
026 import org.apache.directory.shared.ldap.name.LdapDN;
027
028
029 /**
030 * A PrincipalStore backing entries in a DirectoryService.
031 *
032 *
033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034 * @version $Rev$, $Date$
035 */
036 public class DirectoryPrincipalStore implements PrincipalStore
037 {
038 /** The directory service backing store for this PrincipalStore. */
039 private final DirectoryService directoryService;
040 private final LdapDN searchBaseDn;
041
042
043 /**
044 * Creates a new instance of DirectoryPrincipalStore.
045 *
046 * @param directoryService backing store for this PrincipalStore
047 */
048 public DirectoryPrincipalStore( DirectoryService directoryService, LdapDN searchBaseDn )
049 {
050 this.directoryService = directoryService;
051 this.searchBaseDn = searchBaseDn;
052 }
053
054
055 /* (non-Javadoc)
056 * @see org.apache.directory.server.kerberos.shared.store.PrincipalStore#changePassword(javax.security.auth.kerberos.KerberosPrincipal, java.lang.String)
057 */
058 public String changePassword( KerberosPrincipal principal, String newPassword ) throws Exception
059 {
060 SingleBaseSearch singleBaseSearch = new SingleBaseSearch( directoryService, searchBaseDn );
061 return singleBaseSearch.changePassword( principal, newPassword );
062 }
063
064
065 /* (non-Javadoc)
066 * @see org.apache.directory.server.kerberos.shared.store.PrincipalStore#getPrincipal(javax.security.auth.kerberos.KerberosPrincipal)
067 */
068 public PrincipalStoreEntry getPrincipal( KerberosPrincipal principal ) throws Exception
069 {
070 SingleBaseSearch singleBaseSearch = new SingleBaseSearch( directoryService, searchBaseDn );
071 return singleBaseSearch.getPrincipal( principal );
072 }
073 }