Commit b5b248f9 by Tuomas Riihimäki

Auth module permission refactor

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