1 22 package org.jboss.test.xml.mbeanserver; 23 24 import java.util.ArrayList ; 25 import java.util.Arrays ; 26 import java.util.Map ; 27 import java.util.Iterator ; 28 import javax.security.auth.login.AppConfigurationEntry ; 29 30 34 public class AuthenticationInfo 35 { 36 private String name; 37 private ArrayList loginModules = new ArrayList (); 38 39 public AuthenticationInfo() 40 { 41 } 43 public AuthenticationInfo(String name) 44 { 45 this.name = name; 46 } 48 49 public String getName() 50 { 51 return name; 52 } 53 public void setName(String name) 54 { 55 this.name = name; 57 } 58 59 62 public AppConfigurationEntry [] copyAppConfigurationEntry() 63 { 64 AppConfigurationEntry [] copy = new AppConfigurationEntry [loginModules.size()]; 65 for(int i = 0; i < copy.length; i ++) 66 { 67 AppConfigurationEntry entry = (AppConfigurationEntry ) loginModules.get(i); 68 copy[i] = new AppConfigurationEntry (entry.getLoginModuleName(), 69 entry.getControlFlag(), entry.getOptions()); 70 } 71 return copy; 72 } 73 74 public void addAppConfigurationEntry(AppConfigurationEntry entry) 75 { 76 loginModules.add(entry); 78 } 79 82 public AppConfigurationEntry [] getAppConfigurationEntry() 83 { 84 AppConfigurationEntry [] entries = new AppConfigurationEntry [loginModules.size()]; 85 loginModules.toArray(entries); 86 return entries; 87 } 88 91 public void setAppConfigurationEntry(AppConfigurationEntry [] loginModules) 92 { 93 this.loginModules.addAll(Arrays.asList(loginModules)); 94 } 95 96 public String toString() 97 { 98 StringBuffer buffer = new StringBuffer ("AppConfigurationEntry[]:\n"); 99 for(int i = 0; i < loginModules.size(); i ++) 100 { 101 AppConfigurationEntry entry = (AppConfigurationEntry ) loginModules.get(i); 102 buffer.append("["+i+"]"); 103 buffer.append("\nLoginModule Class: "+entry.getLoginModuleName()); 104 buffer.append("\nControlFlag: "+entry.getControlFlag()); 105 buffer.append("\nOptions:"); 106 Map options = entry.getOptions(); 107 Iterator iter = options.entrySet().iterator(); 108 while( iter.hasNext() ) 109 { 110 Map.Entry e = (Map.Entry ) iter.next(); 111 buffer.append("name="+e.getKey()); 112 buffer.append(", value="+e.getValue()); 113 buffer.append("\n"); 114 } 115 } 116 return buffer.toString(); 117 } 118 119 } 120 | Popular Tags |