Methods Summary |
---|
private static com.sun.enterprise.security.auth.realm.Realm | _getInstance(java.lang.String name)This is a private method for getting realm instance.
If realm does not exist, then it will not return null rather than
throw exception.
Realm retval = null;
retval = (Realm) loadedRealms.get (name);
// Some tools as well as numerous other locations assume that
// getInstance("default") always works; keep them from breaking
// until code can be properly cleaned up. 4628429
// Also note that for example the appcontainer will actually create
// a Subject always containing realm='default' so this notion
// needs to be fixed/handled.
if ( (retval == null) && (RI_DEFAULT.equals(name)) ) {
retval = (Realm) loadedRealms.get (defaultRealmName);
}
return retval;
|
protected java.lang.String[] | addAssignGroups(java.lang.String[] grps)Add assign groups to given Vector of groups.
To be used by getGroupNames.
String[] resultGroups = grps;
if (assignGroups != null && assignGroups.size() > 0) {
List<String> groupList = new ArrayList<String>();
if (grps != null && grps.length > 0) {
for (String grp : grps) {
groupList.add(grp);
}
}
for (String agrp : assignGroups) {
if (!groupList.contains(agrp)) {
groupList.add(agrp);
}
}
resultGroups = groupList.toArray(new String[groupList.size()]);
}
return resultGroups;
|
public int | compareTo(java.lang.Object realm)Compares a realm to another. The comparison first considers the
authentication type, so that realms supporting the same kind of
user authentication are grouped together. Then it compares realm
realm names. Realms compare "before" other kinds of objects (i.e.
there's only a partial order defined, in the case that those other
objects compare themselves "before" a realm object).
if (!(realm instanceof Realm)) {
return 1;
}
Realm r = (Realm) realm;
String str = r.getAuthType ();
int temp;
if ((temp = getAuthType ().compareTo (str)) != 0) {
return temp;
}
str = r.getName ();
return getName ().compareTo (str);
|
private static com.sun.enterprise.security.auth.realm.Realm | doInstantiate(java.lang.String name, java.lang.String className, java.util.Properties props)Instantiates a Realm class of the given type and invokes its init()
try {
Class realmClass = Class.forName(className);
Object obj = realmClass.newInstance();
Realm r = (Realm) obj;
r.setName(name);
r.init(props);
loadedRealms.put(name, r);
return r;
} catch(Exception e) {
throw new BadRealmException(e);
}
|
public abstract java.lang.String | getAuthType()Returns a short (preferably less than fifteen characters) description
of the kind of authentication which is supported by this realm.
|
public abstract AuthenticationHandler | getAuthenticationHandler()Returns an AuthenticationHandler object which can be used to
authenticate within this realm.
|
public static com.sun.enterprise.security.auth.realm.Realm | getDefaultInstance()Convenience method which returns the Realm object representing
the current default realm. Equivalent to
getInstance(getDefaultRealm()).
return getInstance(defaultRealmName);
|
public static java.lang.String | getDefaultRealm()Returns the name of the default realm.
return defaultRealmName;
|
public abstract java.util.Enumeration | getGroupNames()Returns names of all the groups in this particular realm.
|
public abstract java.util.Enumeration | getGroupNames(java.lang.String username)Returns the name of all the groups that this user belongs to
|
public static com.sun.enterprise.security.auth.realm.Realm | getInstance(java.lang.String name)Returns the realm identified by the name which is passed
as a parameter. This function knows about all the realms
which exist; it is not possible to store (or create) one
which is not accessible through this routine.
Realm retval = _getInstance(name);
if (retval == null) {
throw new NoSuchRealmException(
localStrings.getLocalString("realm.no_such_realm",
name + " realm does not exist.",
new Object[] { name }));
}
return retval;
|
public java.lang.String | getJAASContext()Returns name of JAAS context used by this realm.
The JAAS context is defined in server.xml auth-realm element
associated with this realm.
return ctxProps.getProperty(IASRealm.JAAS_CONTEXT_PARAM);
|
public final java.lang.String | getName()Returns the name of this realm.
return myName;
|
protected java.util.Properties | getProperties()Return properties of the realm.
return ctxProps;
|
public java.lang.String | getProperty(java.lang.String name)Get a realm property.
return ctxProps.getProperty(name);
|
public static java.util.Enumeration | getRealmNames()Returns the names of accessible realms.
return loadedRealms.keys();
|
public abstract User | getUser(java.lang.String name)Returns the information recorded about a particular named user.
|
public abstract java.util.Enumeration | getUserNames()Returns names of all the users in this particular realm.
|
protected void | init(java.util.Properties props)Initialize a realm with some properties. This can be used
when instantiating realms from their descriptions. This
method may only be called a single time.
String groupList = props.getProperty(PARAM_GROUPS);
if (groupList != null && groupList.length() > 0) {
this.setProperty(PARAM_GROUPS, groupList);
assignGroups = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(groupList, GROUPS_SEP);
while (st.hasMoreTokens()) {
String grp = (String)st.nextToken();
if (!assignGroups.contains(grp)) {
assignGroups.add(grp);
}
}
}
|
public static com.sun.enterprise.security.auth.realm.Realm | instantiate(java.lang.String name, java.lang.String className, java.util.Properties props)Instantiate a Realm with the given name and properties using the
Class name given. This method is used by iAS and not RI.
return doInstantiate(name, className, props);
|
public static com.sun.enterprise.security.auth.realm.Realm | instantiate(java.lang.String realmName, java.io.File f)Instantiate a Realm with the given name, loading properties from
the given file. This method is only used by RI and is not called
anywhere in iAS.
if (!f.exists() || !f.isFile()) {
throw new FileNotFoundException ();
}
if(_getInstance(realmName) != null) {
throw new BadRealmException(
localStrings.getLocalString("realm.already_exists",
"This Realm already exists."));
}
//
// First load the description from properties.
//
InputStream in = null;
Properties props = new Properties();
try{
in = new FileInputStream(f);
props.load(in);
//
// Then instantiate and initialize, using the single mandatory
// property ("classname").
//
String classname = props.getProperty("classname");
assert (classname != null);
return doInstantiate(realmName, classname, props);
} catch (IOException e) {
throw new BadRealmException(e.toString());
} finally {
if (in != null) {
try {
in.close();
} catch(Exception ex) {
}
}
}
|
public static boolean | isValidRealm(java.lang.String name)Checks if the given realm name is loaded/valid.
if(name == null){
return false;
} else {
return loadedRealms.containsKey(name);
}
|
public abstract void | refresh()Refreshes the realm data so that new users/groups are visible.
|
public static void | setDefaultRealm(java.lang.String realmName)Sets the name of the default realm.
defaultRealmName = realmName;
|
protected final void | setName(java.lang.String name)Assigns the name of this realm, and stores it in the cache
of realms. Used when initializing a newly created in-memory
realm object; if the realm already has a name, there is no
effect.
if (myName != null) {
return;
}
myName = name;
|
public void | setProperty(java.lang.String name, java.lang.String value)Set a realm property.
ctxProps.setProperty(name, value);
|
public java.lang.String | toString()Returns the name of this realm.
return myName;
|
static void | unloadInstance(java.lang.String realmName)Remove realm with given name from cache.
//make sure instance exist
getInstance(realmName);
loadedRealms.remove(realmName);
|
protected static void | updateInstance(com.sun.enterprise.security.auth.realm.Realm realm, java.lang.String name)Replace a Realm instance. Can be used by a Realm subclass to
replace a previously initialized instance of itself. Future
getInstance requests will then obtain the new instance.
Minimal error checking is done. The realm being replaced must
already exist (instantiate() was previously called), the new
instance must be fully initialized properly and it must of course
be of the same class as the previous instance.
Realm oldRealm = (Realm)loadedRealms.get(name);
if (!oldRealm.getClass().equals(realm.getClass())) {
// would never happen unless bug in realm subclass
throw new Error("Incompatible class "+realm.getClass()+
" in replacement realm "+name);
}
realm.setName(oldRealm.getName());
loadedRealms.put(name, realm);
|