{
try
{
JetspeedRunData rundata = (JetspeedRunData) data;
Profile profile = createProfile();
JetspeedUser user = rundata.getJetspeedUser();
// get the media type from the capability map or rundata
profile.setMediaType(getMediaType(rundata, cm));
// Is it a group, role, or user resource?
// It can only be one
String param =
rundata.getParameters().getString(Profiler.PARAM_GROUP);
if (null != param)
{
// GROUP Resource
profile.setGroup(JetspeedSecurity.getGroup(param));
}
else
{
param = rundata.getParameters().getString(Profiler.PARAM_ROLE);
if (null != param)
{
// ROLE Resource
if (user.hasLoggedIn())
// disallow role access for anonymous user
{
profile.setRole(JetspeedSecurity.getRole(param));
}
else
{
profile.setAnonymous(true);
profile.setUser(user);
}
}
else // it must be a user resource or anonymous resource
{
// accessing another user's resource
param =
rundata.getParameters().getString(Profiler.PARAM_USER);
if (null != param)
{
if (param
.equals(JetspeedSecurity.getAnonymousUserName()))
{
profile.setAnonymous(true);
}
if (user.getUserName().equals(param))
{
profile.setUser(user);
}
else
{
profile.setUser(JetspeedSecurity.getUser(param));
}
}
else
{
profile.setAnonymous(
user.getUserName().equals(
JetspeedSecurity.getAnonymousUserName()));
profile.setUser(user);
}
}
}