Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2011-08-26 18:00:02 +0000
committerJesse McConnell2011-09-20 15:11:26 +0000
commitdf0aab1f49b395fe4bb903fcef2c3d214a79dc9e (patch)
treeac16289e1b3d396d52be2f72ca49fffa8cc2cd17
parent129a66f57918b972df7674c94180a687977f7b26 (diff)
downloadorg.eclipse.jetty.project-df0aab1f49b395fe4bb903fcef2c3d214a79dc9e.tar.gz
org.eclipse.jetty.project-df0aab1f49b395fe4bb903fcef2c3d214a79dc9e.tar.xz
org.eclipse.jetty.project-df0aab1f49b395fe4bb903fcef2c3d214a79dc9e.zip
PropertyUserStore: Code Format
-rw-r--r--jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java96
1 files changed, 46 insertions, 50 deletions
diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java
index 67a207042f..b10342e303 100644
--- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java
+++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/jaas/spi/PropertyFileLoginModule.java
@@ -31,108 +31,104 @@ import org.eclipse.jetty.util.log.Logger;
/**
* PropertyFileLoginModule
- *
- *
+ *
+ *
*/
public class PropertyFileLoginModule extends AbstractLoginModule
{
private static final Logger LOG = Log.getLogger(PropertyFileLoginModule.class);
public static final String DEFAULT_FILENAME = "realm.properties";
- public static final Map<String, Map<String, UserInfo>> fileMap = new HashMap<String, Map<String, UserInfo>>();
-
+ public static final Map<String, Map<String, UserInfo>> fileMap = new HashMap<String, Map<String, UserInfo>>();
+
private String propertyFileName;
-
-
- /**
+ /**
* Read contents of the configured property file.
*
- * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)
+ * @see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map,
+ * java.util.Map)
* @param subject
* @param callbackHandler
* @param sharedState
* @param options
*/
- public void initialize(Subject subject, CallbackHandler callbackHandler,
- Map<String,?> sharedState, Map<String,?> options)
+ public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options)
{
- super.initialize(subject, callbackHandler, sharedState, options);
+ super.initialize(subject,callbackHandler,sharedState,options);
loadProperties((String)options.get("file"));
}
-
-
-
- public void loadProperties (String filename)
+
+ public void loadProperties(String filename)
{
File propsFile;
-
+
if (filename == null)
{
- propsFile = new File(System.getProperty("user.dir"), DEFAULT_FILENAME);
- //look for a file called realm.properties in the current directory
- //if that fails, look for a file called realm.properties in $jetty.home/etc
+ propsFile = new File(System.getProperty("user.dir"),DEFAULT_FILENAME);
+ // look for a file called realm.properties in the current directory
+ // if that fails, look for a file called realm.properties in $jetty.home/etc
if (!propsFile.exists())
- propsFile = new File(System.getProperty("jetty.home"), DEFAULT_FILENAME);
+ propsFile = new File(System.getProperty("jetty.home"),DEFAULT_FILENAME);
}
else
{
propsFile = new File(filename);
}
-
- //give up, can't find a property file to load
+
+ // give up, can't find a property file to load
if (!propsFile.exists())
{
LOG.warn("No property file found");
throw new IllegalStateException ("No property file specified in login module configuration file");
}
-
-
-
+
try
{
this.propertyFileName = propsFile.getCanonicalPath();
if (fileMap.get(propertyFileName) != null)
{
- if (LOG.isDebugEnabled()) {LOG.debug("Properties file "+propertyFileName+" already in cache, skipping load");}
+ if (Log.isDebugEnabled())
+ {
+ Log.debug("Properties file " + propertyFileName + " already in cache, skipping load");
+ }
return;
}
-
+
Map<String, UserInfo> userInfoMap = new HashMap<String, UserInfo>();
Properties props = new Properties();
props.load(new FileInputStream(propsFile));
- Iterator<Map.Entry<Object,Object>> iter = props.entrySet().iterator();
- while(iter.hasNext())
+ Iterator<Map.Entry<Object, Object>> iter = props.entrySet().iterator();
+ while (iter.hasNext())
{
-
- Map.Entry<Object,Object> entry = iter.next();
- String username=entry.getKey().toString().trim();
- String credentials=entry.getValue().toString().trim();
- String roles=null;
- int c=credentials.indexOf(',');
- if (c>0)
+
+ Map.Entry<Object, Object> entry = iter.next();
+ String username = entry.getKey().toString().trim();
+ String credentials = entry.getValue().toString().trim();
+ String roles = null;
+ int c = credentials.indexOf(',');
+ if (c > 0)
{
- roles=credentials.substring(c+1).trim();
- credentials=credentials.substring(0,c).trim();
+ roles = credentials.substring(c + 1).trim();
+ credentials = credentials.substring(0,c).trim();
}
- if (username!=null && username.length()>0 &&
- credentials!=null && credentials.length()>0)
+ if (username != null && username.length() > 0 && credentials != null && credentials.length() > 0)
{
ArrayList<String> roleList = new ArrayList<String>();
- if(roles!=null && roles.length()>0)
+ if (roles != null && roles.length() > 0)
{
StringTokenizer tok = new StringTokenizer(roles,", ");
-
+
while (tok.hasMoreTokens())
roleList.add(tok.nextToken());
}
-
- userInfoMap.put(username, (new UserInfo(username, Credential.getCredential(credentials.toString()), roleList)));
+
+ userInfoMap.put(username,(new UserInfo(username,Credential.getCredential(credentials.toString()),roleList)));
}
}
-
- fileMap.put(propertyFileName, userInfoMap);
+
+ fileMap.put(propertyFileName,userInfoMap);
}
catch (Exception e)
{
@@ -141,13 +137,13 @@ public class PropertyFileLoginModule extends AbstractLoginModule
}
}
- /**
- * Don't implement this as we want to pre-fetch all of the
- * users.
+ /**
+ * Don't implement this as we want to pre-fetch all of the users.
+ *
* @param username
* @throws Exception
*/
- public UserInfo getUserInfo (String username) throws Exception
+ public UserInfo getUserInfo(String username) throws Exception
{
Map<?, ?> userInfoMap = (Map<?, ?>)fileMap.get(propertyFileName);
if (userInfoMap == null)

Back to the top