001/******************************************************************************* 002 * Copyright 2014 The MITRE Corporation 003 * and the MIT Kerberos and Internet Trust Consortium 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 ******************************************************************************/ 017package org.mitre.openid.connect.repository; 018 019import java.util.Collection; 020 021import org.mitre.openid.connect.model.UserInfo; 022 023/** 024 * UserInfo repository interface 025 * 026 * @author Michael Joseph Walsh 027 * 028 */ 029public interface UserInfoRepository { 030 031 /** 032 * Returns the UserInfo for the given subject 033 * 034 * @param sub 035 * the subject of the UserInfo 036 * @return a valid UserInfo if it exists, null otherwise 037 */ 038 public UserInfo getBySubject(String sub); 039 040 /** 041 * Persists a UserInfo 042 * 043 * @param user 044 * @return 045 */ 046 public UserInfo save(UserInfo userInfo); 047 048 /** 049 * Removes the given UserInfo from the repository 050 * 051 * @param userInfo 052 * the UserInfo object to remove 053 */ 054 public void remove(UserInfo userInfo); 055 056 /** 057 * Return a collection of all UserInfos managed by this repository 058 * 059 * @return the UserInfo collection, or null 060 */ 061 public Collection<? extends UserInfo> getAll(); 062 063 /** 064 * Get a UserInfo object by its preferred_username field 065 * @param username 066 * @return 067 */ 068 public UserInfo getByUsername(String username); 069 070}