X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=security%2Fimpl%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsecurity%2Fauthorization%2FTestUserAccessor.java;fp=security%2Fimpl%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fsecurity%2Fauthorization%2FTestUserAccessor.java;h=0000000000000000000000000000000000000000;hb=9449ea0f360f6e9c14057db57f3ee0bfba947ab4;hp=7ff738dfeef4606268aa3097443c7275a3e7abbe;hpb=e8b988e92306a4aea2f047af1b48588147288831;p=utils diff --git a/security/impl/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java b/security/impl/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java deleted file mode 100644 index 7ff738df..00000000 --- a/security/impl/src/test/java/org/wamblee/security/authorization/TestUserAccessor.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2005-2010 the original author or authors. - * - * 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. - */ -package org.wamblee.security.authorization; - -import org.wamblee.security.authentication.InMemoryGroupSet; -import org.wamblee.security.authentication.InMemoryUserSet; -import org.wamblee.security.authentication.RegexpNameValidator; -import org.wamblee.security.authentication.UserAccessor; -import org.wamblee.security.authentication.UserAdministration; -import org.wamblee.security.authentication.UserAdministrationImpl; -import org.wamblee.security.authentication.UserMgtException.Reason; -import org.wamblee.security.encryption.Md5HexMessageDigester; - - -/** - * User access that always returns a user that belongs to a fixed group. - * - * @author Erik Brakkee - */ -public class TestUserAccessor implements UserAccessor { - private static final String USER = "erik"; - - private static final String PASSWORD = "abc123"; - - private static final String GROUP = "users"; - - private UserAdministration userAdmin; - - public TestUserAccessor() { - userAdmin = new UserAdministrationImpl( - new InMemoryUserSet(new RegexpNameValidator( - RegexpNameValidator.PASSWORD_PATTERN, Reason.INVALID_PASSWORD, - "Password must contain at least 6 characters"), - new Md5HexMessageDigester()), new InMemoryGroupSet(), - new RegexpNameValidator(RegexpNameValidator.ID_PATTERN, - Reason.INVALID_USERNAME, "Invalid user"), - new RegexpNameValidator(RegexpNameValidator.ID_PATTERN, - Reason.INVALID_GROUPNAME, "Invalid group")); - - userAdmin.createGroup(GROUP); - userAdmin.createUser(USER, PASSWORD); - userAdmin.addUserToGroup(USER, GROUP); - } - - // NOTE: This is only for test. Normally the user accessor would not depend - // on user administration. This just ensures that a user administration is created - // that knows about the given user. - public UserAdministration getUserAdmin() { - return userAdmin; - } - - /* - * (non-Javadoc) - * - * @see org.wamblee.usermgt.UserAccessor#getCurrentUser() - */ - public String getCurrentUser() { - return USER; - } -}