Commit b5b248f9 by Tuomas Riihimäki

Auth module permission refactor

1 parent 49b8d99e
......@@ -66,6 +66,7 @@ public class BortalLoginModule extends AppservPasswordLoginModule {
* @throws javax.security.auth.login.LoginException
*/
@Override
protected void authenticateUser() throws LoginException {
log((new StringBuilder()).append("CustomRealm Auth Info:_username:")
.append(_username)
......@@ -115,12 +116,19 @@ public class BortalLoginModule extends AppservPasswordLoginModule {
}
ArrayList<String> authenticatedGroups = new ArrayList<String>();
for (int i = 0; enumeration != null && enumeration.hasMoreElements(); i++)
authenticatedGroups.add(enumeration.nextElement());
if (enumeration != null) {
while (enumeration.hasMoreElements()) {
authenticatedGroups.add(enumeration.nextElement());
}
}
// Call commitUserAuthentication with the groupNames the user belongs to
commitUserAuthentication(authenticatedGroups.toArray(new String[0]));
String[] groups = authenticatedGroups.toArray(new String[authenticatedGroups.size()]);
System.out.println("groups: " + groups.length);
for (String str : groups) {
System.out.println("Str " + str);
}
commitUserAuthentication(groups);
}
......
......@@ -48,8 +48,6 @@ import com.sun.enterprise.security.auth.realm.InvalidOperationException;
import com.sun.enterprise.security.auth.realm.NoSuchRealmException;
import com.sun.enterprise.security.auth.realm.NoSuchUserException;
/**
*
* @author nithyasubramanian SampleRealm - class extending AppservRealm Sample
......@@ -58,7 +56,8 @@ import com.sun.enterprise.security.auth.realm.NoSuchUserException;
public class BortalRealm extends AppservRealm {
// private static final Logger logger = LoggerFactory.getLogger(BortalRealm.class);
// private static final Logger logger =
// LoggerFactory.getLogger(BortalRealm.class);
private static final String JAAS_BEAN_JNDI = "java:global/LanBortal/LanBortalBeans/JaasBean!fi.insomnia.bortal.beans.JaasBeanRemote";
......@@ -71,22 +70,24 @@ public class BortalRealm extends AppservRealm {
* @throws com.sun.enterprise.security.auth.realm.BadRealmException
* @throws com.sun.enterprise.security.auth.realm.NoSuchRealmException
*/
@Override
public void init(Properties properties)
throws BadRealmException, NoSuchRealmException {
super.init(properties);
log("Init BortalRealm");
String propJaasContext = properties.getProperty(JAAS_CONTEXT_PARAM);
if (propJaasContext != null) {
setProperty(JAAS_CONTEXT_PARAM, propJaasContext);
}
}
/**
*
* @return authType
*/
@Override
public String getAuthType() {
return "Omnia Lan system authentication Realm";
}
......@@ -98,6 +99,7 @@ public class BortalRealm extends AppservRealm {
* @throws com.sun.enterprise.security.auth.realm.InvalidOperationException
* @throws com.sun.enterprise.security.auth.realm.NoSuchUserException
*/
@Override
public Enumeration<String> getGroupNames(String user)
throws InvalidOperationException, NoSuchUserException {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!