• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

security migration from weblogic to Jboss

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I'm new to Jboss, currently I'm trying to migrate my app from weblogic to jboss. My problem is that in my app, I got weblogic specific security code that I'm trying to convert into Jboss specific. I don't know what is Jboss equivalent security code. If any body know, please forward the equivalent code. I will really appreciate that.

Thanks in advance


Here is my weblogic specific code

import za.co.rmba.di.ejb.*;
import za.co.rmba.di.beans.*;
import za.co.rmba.di.util.*;
import za.co.rmba.di.exception.*;
import java.math.BigDecimal;
import javax.ejb.*;
import java.rmi.*;
import java.security.acl.*;
import java.util.*;
import java.math.*;
import javax.servlet.http.*;
import weblogic.security.acl.*;

public class UserDelegate {

private UserSession session;
private static final Class homeClass = za.co.rmba.di.ejb.UserSessionHome.class;


public UserBean getUser(HttpServletRequest request, String database) throws DataAccessException, RemoteException, AuthenticationException {
UserBean bean = null;
try {
ServiceLocator.getInitialContext(request.getParameter("username"), request.getParameter("password"));
if (hasRole("DI")) {
bean = session.getUser(request.getParameter("username"),database);
}
else {
throw new Exception("User does not have access to DI.");
}
}
catch (Exception e) {
throw new AuthenticationException("Could not validate user.");
}
return bean;
}

private static User getUser() {
return Security.getCurrentUser();
}

private static Collection getRoles() {
Collection roles = new ArrayList();
ListableRealm realm = (ListableRealm) getUser().getRealm();
Enumeration enum = realm.getGroups();
while (enum.hasMoreElements()) {
Group grp = (Group) enum.nextElement();
if ( (grp.getName() != "everyone") && (grp.isMember(getUser())) ) {
roles.add(grp);
}
}
return roles;
}

private static boolean hasRole(String aRoleName) {
boolean hasRole = false;
Iterator iter = getRoles().iterator();
while (iter.hasNext()) {
if ( ((Group) iter.next()).getName().equals(aRoleName) ) {
hasRole = true;
}
}
return hasRole;
}



public static InitialContext getInitialContext(String userName, String password) throws javax.naming.AuthenticationException, ServiceLocatorException {
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL,
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, userName);
env.put(Context.SECURITY_CREDENTIALS, password);
return new InitialContext(env);
}
catch (javax.naming.AuthenticationException ae) {
throw ae;
}
catch (NamingException ne) {
throw new ServiceLocatorException("ServiceLocatorException (NamingException) while trying to get the InitialContext.");
}
catch (Exception e) {
throw new ServiceLocatorException("ServiceLocatorException (Unknown) while trying to get the InitialContext.");
}
}
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this discussion to "JBoss" forum...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic