Skip to content

Commit

Permalink
Merge branch '1.8.11' of github.com:atricore/josso1 into 1.8.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianluca Brigandi committed Mar 17, 2017
2 parents bdff325 + 4ae6359 commit 984bd4d
Show file tree
Hide file tree
Showing 27 changed files with 2,645 additions and 399 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
SingleSignOnEntry entry = agent.processRequest(relayRequest);
if (entry == null) {
// This is wrong! We should have an entry here!
log.error("Outbound relaying failed for assertion id [" + assertionId + "], no Principal found.");
// Throw an exception and let the container send the INERNAL SERVER ERROR
log.debug("Outbound relaying failed for assertion id [" + assertionId + "], no Principal found.");
// Throw an exception and let the container deal with it
throw new ServletException("No Principal found. Verify your SSO Agent Configuration!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@
/**
* Acts as a Catalina Session wrapper.
*
* @author <a href="mailto:[email protected]">Gianluca Brigandi</a>
* @author <a href="mailto:[email protected]">Gianluca Brigandi</a>
* @version CVS $Id: CatalinaLocalSession.java 974 2009-01-14 00:39:45Z sgonzalez $
*/
public class CatalinaLocalSession extends LocalSessionImpl {

public CatalinaLocalSession( Session catalinaSession) {
public CatalinaLocalSession(Session catalinaSession) {
super();

setWrapped(catalinaSession);
setMaxInactiveInterval(catalinaSession.getMaxInactiveInterval());

setWrapped(catalinaSession);
setMaxInactiveInterval(catalinaSession.getMaxInactiveInterval());
}

@Override
public String toString() {
return "CatalinaLocalSession [toString()=" + super.toString() + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import java.security.Principal;

/**
* Catalina Realm replacement that will authenticate users
* Catalina Realm replacement that will authenticate users
* directly against the gateway.
*/
public class CatalinaNativeRealm extends RealmBase {
Expand All @@ -49,58 +49,58 @@ public class CatalinaNativeRealm extends RealmBase {
* Descriptive information about this Realm implementation.
*/
protected static final String name = "CatalinaNativeRealm";
@Override
public Principal authenticate(String username, String credentials) {
try {

@Override
public Principal authenticate(String username, String credentials) {
try {
SSOAgentRequest request = AbstractSSOAgent._currentRequest.get();
SSOAgent agent = Lookup.getInstance().lookupSSOAgent();

SSOIdentityManagerService im = request.getConfig(agent).getIdentityManagerService();
if (im == null)
im = agent.getSSOIdentityManager();
String requester = "";
// Check for nulls ?

String requester = "";
// Check for nulls ?

if (request != null)
requester = request.getRequester();
requester = request.getRequester();
else
log.warn("No SSO Agent request found in thread local variable, can't identify requester");

SSOUser ssoUser = im.findUserInSession(requester, username);
Principal principal = null;
if (ssoUser != null) {
Subject subject = new Subject();
subject.getPrincipals().add(ssoUser);

Principal principal = null;

if (ssoUser != null) {
Subject subject = new Subject();
subject.getPrincipals().add(ssoUser);
SSORole[] ssoRolePrincipals = im.findRolesBySSOSessionId(requester, username);
for (int i=0; i < ssoRolePrincipals.length; i++) {
subject.getPrincipals().add(ssoRolePrincipals[i]);
}
// Return the appropriate Principal for this authenticated Subject
principal = createPrincipal(username, subject);
}
return principal;
} catch (SSOIdentityException e) {
for (int i = 0; i < ssoRolePrincipals.length; i++) {
subject.getPrincipals().add(ssoRolePrincipals[i]);
}
// Return the appropriate Principal for this authenticated Subject
principal = createPrincipal(username, subject);
}

return principal;
} catch (SSOIdentityException e) {
// Ignore this ... (user does not exist for this session)
if (log.isDebugEnabled()) {
log.debug(e.getMessage());
log.debug(e.getMessage());
}
return null;
} catch (Exception e) {
log.error("Session authentication failed : " + username, e);
log.error("Session authentication failed : " + username, e);
throw new RuntimeException("Fatal error authenticating session : " + e);
}
}
}

/**
/**
* Construct and return a java.security.Principal instance
* representing the authenticated user for the specified Subject. If no
* such Principal can be constructed, return null.
*
* <p>
* The Principal constructed is CatalinaSSOUser which is a SSOUser.
* The Partner Application can access SSOUser-specific properties that are not available
* in GenericPrincipal.
Expand All @@ -111,18 +111,18 @@ protected Principal createPrincipal(String username, Subject subject) {
return CatalinaSSOUser.newInstance(this, subject);
}

@Override
protected String getName() {
return name;
}
@Override
protected String getName() {
return name;
}

@Override
protected String getPassword(String username) {
return null;
}
@Override
protected String getPassword(String username) {
return null;
}

@Override
protected Principal getPrincipal(String username) {
return authenticate(username, username);
}
@Override
protected Principal getPrincipal(String username) {
return authenticate(username, username);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,25 @@
import org.apache.catalina.Container;
import org.apache.catalina.Context;
import org.apache.catalina.Realm;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.josso.agent.SSOAgentRequest;
import org.josso.agent.http.HttpSSOAgent;

import java.security.Principal;

/**
* @author <a href="mailto:[email protected]">Gianluca Brigandi</a>
* @version CVS $Id: CatalinaSSOAgent.java 974 2009-01-14 00:39:45Z sgonzalez $
* @org.apache.xbean.XBean element="agent"
*
* <p>
* Catalina SSO Agent Implementation that authenticates using the configured Catalina Realm's
* Gateway SSO Login module.
*
* @author <a href="mailto:[email protected]">Gianluca Brigandi</a>
* @version CVS $Id: CatalinaSSOAgent.java 974 2009-01-14 00:39:45Z sgonzalez $
*/
public class CatalinaSSOAgent extends HttpSSOAgent {

private static final Log LOG = LogFactory.getLog(CatalinaSSOAgent.class);

private Container _container;

public CatalinaSSOAgent() {
Expand All @@ -50,7 +53,7 @@ public CatalinaSSOAgent() {

public CatalinaSSOAgent(Container container) {
super();
_container = container;
_container = container;

}

Expand Down Expand Up @@ -95,25 +98,19 @@ protected Principal authenticate(SSOAgentRequest request) {
Principal p = realm.authenticate(r.getSessionId(), r.getSessionId());

if (debug > 0)
log("Received principal : " + p + "[" + ( p != null ? p.getClass().getName() : "<null>" ) +"]");
log("Received principal : " + p + "[" + (p != null ? p.getClass().getName() : "<null>") + "]");

return p;
}

protected void log(String message) {
if (_container != null) {
if (_container.getLogger().isDebugEnabled())
_container.getLogger().debug(this.toString() + ": " + message);
} else
System.out.println(this.toString() + ": " + message);
if (LOG.isDebugEnabled())
LOG.debug(message);
}

protected void log(String message, Throwable throwable) {
if (_container != null) {
if (_container.getLogger().isDebugEnabled())
_container.getLogger().debug(this.toString() + ": " + message, throwable);
} else
System.out.println(this.toString() + ": " + message);
if (LOG.isDebugEnabled())
LOG.debug(message, throwable);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void removeSessionListener(LocalSessionListener sessionListener) {
}

public void invalidate() {
((Session)_wrapped).expire();
((Session) _wrapped).expire();
}

public void setWrapped(Object wrapped) {
Expand All @@ -103,5 +103,11 @@ public void setWrapped(Object wrapped) {
public Object getWrapped() {
return _wrapped;
}

@Override
public String toString() {
return "LocalSessionImpl [_creationTime=" + _creationTime + ", _id=" + _id + ", _lastAccessedTime="
+ _lastAccessedTime + ", _maxInactiveInterval=" + _maxInactiveInterval + ", _wrapped=" + _wrapped + "]";
}
}

Loading

0 comments on commit 984bd4d

Please sign in to comment.