    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 */
    019package org.apache.wiki.auth.user;
    020
    021import org.apache.wiki.api.core.Engine;
    022import org.apache.wiki.auth.NoSuchPrincipalException;
    023
    024import java.security.Principal;
    025import java.util.Properties;
    026
    027
    028/**
    029 * This is a database that gets used if nothing else is available. It does nothing of note - it just mostly throws
    030 * NoSuchPrincipalExceptions if someone tries to log in.
    031 */
    032public class DummyUserDatabase extends AbstractUserDatabase {
    033
    034    /**
    035     * No-op.
    036     * @param loginName the login name to delete
    037     */
    038    @Override
    039    public void deleteByLoginName( final String loginName ) {
    040        // No operation
    041    }
    042
    043    /**
    044     * No-op; always throws <code>NoSuchPrincipalException</code>.
    045     * @param index the name to search for
    046     * @return the user profile
    047     * @throws NoSuchPrincipalException always...
    048     */
    049    @Override
    050    public UserProfile findByEmail(final String index) throws NoSuchPrincipalException {
    051        throw new NoSuchPrincipalException("No user profiles available");
    052    }
    053
    054    /**
    055     * No-op; always throws <code>NoSuchPrincipalException</code>.
    056     * @param index the name to search for
    057     * @return the user profile
    058     * @throws NoSuchPrincipalException always...
    059     */
    060    @Override
    061    public UserProfile findByFullName(final String index) throws NoSuchPrincipalException {
    062        throw new NoSuchPrincipalException("No user profiles available");
    063    }
    064
    065    /**
    066     * No-op; always throws <code>NoSuchPrincipalException</code>.
    067     * @param index the name to search for
    068     * @return the user profile
    069     * @throws NoSuchPrincipalException always...
    070     */
    071    @Override
    072    public UserProfile findByLoginName(final String index) throws NoSuchPrincipalException {
    073        throw new NoSuchPrincipalException("No user profiles available");
    074    }
    075
    076    /**
    077     * No-op; always throws <code>NoSuchPrincipalException</code>.
    078     * @param uid the unique identifier to search for
    079     * @return the user profile
    080     * @throws NoSuchPrincipalException always...
    081     */
    082    @Override
    083    public UserProfile findByUid( final String uid ) throws NoSuchPrincipalException {
    084        throw new NoSuchPrincipalException("No user profiles available");
    085    }
    086    /**
    087     * No-op; always throws <code>NoSuchPrincipalException</code>.
    088     * @param index the name to search for
    089     * @return the user profile
    090     * @throws NoSuchPrincipalException always...
    091     */
    092    @Override
    093    public UserProfile findByWikiName(final String index) throws NoSuchPrincipalException {
    094        throw new NoSuchPrincipalException("No user profiles available");
    095    }
    096
    097    /**
    098     * No-op.
    099     * @return a zero-length array
    100     */
    101    @Override
    102    public Principal[] getWikiNames() {
    103        return new Principal[0];
    104    }
    105
    106    /**
    107     * No-op.
    108     *
    109     * @param engine the wiki engine
    110     * @param props the properties used to initialize the wiki engine
    111     */
    112    @Override
    113    public void initialize( final Engine engine, final Properties props ) {
    114        this.m_engine = engine;
    115    }
    116
    117    /**
    118     * No-op; always throws <code>NoSuchPrincipalException</code>.
    119     * @param loginName the login name
    120     * @param newName the proposed new login name
    121     * @throws NoSuchPrincipalException always...
    122     */
    123    @Override
    124    public void rename( final String loginName, final String newName ) throws NoSuchPrincipalException {
    125        throw new NoSuchPrincipalException("No user profiles available");
    126    }
    127
    128    /**
    129     * No-op.
    130     * @param profile the user profile
    131     */
    132    @Override
    133    public void save( final UserProfile profile ) {
    134    }
    135
    136}