Author: rareddy
Date: 2012-05-24 14:00:40 -0400 (Thu, 24 May 2012)
New Revision: 4140
Modified:
branches/7.7.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
branches/7.7.x/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
Log:
TEIID-2055: Further enhancements to make sure the security context and logged in user are
both in sync
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
===================================================================
---
branches/7.7.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2012-05-24
16:46:59 UTC (rev 4139)
+++
branches/7.7.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2012-05-24
18:00:40 UTC (rev 4140)
@@ -59,6 +59,7 @@
private String securitydomain;
private Object credentials;
private SecurityHelper securityHelper;
+ private Object securityContext;
public TeiidLoginContext(SecurityHelper helper) {
this.securityHelper = helper;
@@ -79,6 +80,7 @@
this.userName = getUserName(existing)+AT+domain;
this.securitydomain = domain;
this.loginContext = createLoginContext(domain, existing);
+ this.securityContext =
this.securityHelper.getSecurityContext(this.securitydomain);
return;
}
}
@@ -118,7 +120,16 @@
this.loginContext.login();
this.userName = baseUsername+AT+domain;
this.securitydomain = domain;
- return;
+ Subject subject = this.loginContext.getSubject();
+ Principal principal = null;
+ for(Principal p:subject.getPrincipals()) {
+ if (baseUsername.equals(p.getName())) {
+ principal = p;
+ break;
+ }
+ }
+ this.securityContext =
this.securityHelper.createSecurityContext(this.securitydomain, principal, credentials,
subject);
+ return;
} catch (LoginException e) {
LogManager.logDetail(LogConstants.CTX_SECURITY,e, e.getMessage());
}
@@ -158,22 +169,7 @@
}
public Object getSecurityContext() {
- Object sc = null;
- if (this.loginContext != null) {
- sc = this.securityHelper.getSecurityContext(this.securitydomain);
- if ( sc == null){
- Subject subject = this.loginContext.getSubject();
- Principal principal = null;
- for(Principal p:subject.getPrincipals()) {
- if (this.userName.startsWith(p.getName())) {
- principal = p;
- break;
- }
- }
- return this.securityHelper.createSecurityContext(this.securitydomain,
principal, credentials, subject);
- }
- }
- return sc;
+ return securityContext;
}
static String getBaseUsername(String username) {
Modified:
branches/7.7.x/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
---
branches/7.7.x/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2012-05-24
16:46:59 UTC (rev 4139)
+++
branches/7.7.x/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2012-05-24
18:00:40 UTC (rev 4140)
@@ -159,6 +159,9 @@
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL))
{
LogManager.logDetail(LogConstants.CTX_TRANSPORT, "processing message:" +
packet); //$NON-NLS-1$
}
+ if (this.workContext.getSecurityHelper() != null) {
+ this.workContext.getSecurityHelper().clearSecurityContext();
+ }
final ServerWorkItem work = new ServerWorkItem(this, packet.getMessageKey(), packet,
this.csr);
this.workContext.runInContext(work);
}
Show replies by date