1 /* 2 * Copyright (c) 2005-2007 Creative Sphere Limited. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * 10 * Creative Sphere - initial API and implementation 11 * 12 */ 13 14 package org.abstracthorizon.danube.auth; 15 16 import java.util.HashMap; 17 import java.util.Map; 18 19 import javax.security.auth.login.AppConfigurationEntry; 20 import javax.security.auth.login.Configuration; 21 22 /** 23 * Authorisation configuiration that can be defined through spring configuration (or in that matter 24 * any other programmable way. 25 * 26 * @author Daniel Sendula 27 */ 28 public class SpringAuthConfiguration extends Configuration { 29 30 /** Login modules mapped to configuration entries */ 31 protected Map<String, AppConfigurationEntry[]> entries = new HashMap<String, AppConfigurationEntry[]>(); 32 33 /** 34 * Constructor 35 */ 36 public SpringAuthConfiguration() { 37 } 38 39 /** 40 * Establishes itself as a authorisation configuration 41 * 42 */ 43 public void init() { 44 setConfiguration(this); 45 } 46 47 @Override 48 public AppConfigurationEntry[] getAppConfigurationEntry(String loginContext) { 49 return entries.get(loginContext); 50 } 51 52 /** 53 * Sets array of application configuration entry at given login context 54 * @param loginContext login context 55 * @param entries application configuraiton entries 56 */ 57 public void setAppConfigurationEntry(String loginContext, AppConfigurationEntry[] entries) { 58 this.entries.put(loginContext, entries); 59 } 60 61 /** 62 * Removes login context 63 * @param loginContext login context 64 */ 65 public void removeAppConfigurationEntry(String loginContext) { 66 this.entries.remove(loginContext); 67 } 68 69 // public void setAppConfigurationEntry(String name, List<AppConfigurationEntry> entries) { 70 // AppConfigurationEntry[] es = new AppConfigurationEntry[entries.size()]; 71 // es = (AppConfigurationEntry[])entries.toArray(es); 72 // this.entries.put(name, es); 73 // } 74 75 /** 76 * Does nothing 77 */ 78 @Override 79 public void refresh() { 80 } 81 82 }