use of org.teiid.logging.AuditMessage in project teiid by teiid.
the class SessionServiceImpl method closeSession.
@Override
public void closeSession(String sessionID) throws InvalidSessionException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_SECURITY, MessageLevel.DETAIL)) {
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] { "closeSession", sessionID });
}
SessionMetadata info = getSessionInfo(sessionID, true);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// $NON-NLS-1$ //$NON-NLS-2$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, new AuditMessage("session", "logoff", info));
}
if (info.getVDBName() != null) {
try {
dqp.terminateSession(info.getSessionId());
} catch (Exception e) {
LogManager.logWarning(LogConstants.CTX_SECURITY, e, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40018));
}
}
info.setSecurityContext(null);
info.setClosed();
info.getSessionVariables().clear();
}
use of org.teiid.logging.AuditMessage in project teiid by teiid.
the class AuthorizationValidationVisitor method logRequest.
private void logRequest(Set<String> resources, Context context) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// Audit - request
// $NON-NLS-1$
AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-request", resources.toArray(new String[resources.size()]), commandContext);
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
}
}
use of org.teiid.logging.AuditMessage in project teiid by teiid.
the class AuthorizationValidationVisitor method logResult.
private void logResult(Set<String> resources, Context context, boolean granted) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
if (granted) {
// $NON-NLS-1$
AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-granted all", resources.toArray(new String[resources.size()]), commandContext);
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
} else {
// $NON-NLS-1$
AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-denied", resources.toArray(new String[resources.size()]), commandContext);
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
}
}
}
use of org.teiid.logging.AuditMessage in project teiid by teiid.
the class SessionServiceImpl method createSession.
@Override
public SessionMetadata createSession(String vdbName, String vdbVersion, AuthenticationType authType, String userName, Credentials credentials, String applicationName, Properties properties) throws LoginException, SessionServiceException {
ArgCheck.isNotNull(applicationName);
ArgCheck.isNotNull(properties);
Object securityContext = null;
Subject subject = null;
String hostName = properties.getProperty(TeiidURL.CONNECTION.CLIENT_HOSTNAME);
String ipAddress = properties.getProperty(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS);
String clientMac = properties.getProperty(TeiidURL.CONNECTION.CLIENT_MAC);
boolean onlyAllowPassthrough = Boolean.valueOf(properties.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, // $NON-NLS-1$
"false"));
AuditMessage.LogonInfo info = new AuditMessage.LogonInfo(vdbName, vdbVersion, authType.toString(), userName, applicationName, hostName, ipAddress, clientMac, onlyAllowPassthrough);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// $NON-NLS-1$ //$NON-NLS-2$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, new AuditMessage("session", "logon-request", info, null));
}
try {
// Validate VDB and version if logging on to server product...
VDBMetaData vdb = null;
if (vdbName != null) {
vdb = getActiveVDB(vdbName, vdbVersion);
if (vdb == null) {
throw new SessionServiceException(RuntimePlugin.Event.TEIID40046, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40046, vdbName, vdbVersion));
}
}
if (sessionMaxLimit > 0 && getActiveSessionsCount() >= sessionMaxLimit) {
throw new SessionServiceException(RuntimePlugin.Event.TEIID40043, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40043, new Long(sessionMaxLimit)));
}
String securityDomain = getSecurityDomain(userName, vdbName, vdbVersion, vdb);
if (securityDomain != null) {
// Authenticate user...
// if not authenticated, this method throws exception
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] { "authenticateUser", userName, applicationName });
String baseUserName = userName;
if (allowSecurityDomainQualifier) {
baseUserName = getBaseUsername(userName);
}
if (onlyAllowPassthrough || authType.equals(AuthenticationType.GSS)) {
subject = this.securityHelper.getSubjectInContext(securityDomain);
if (subject == null) {
if ((!onlyAllowPassthrough || !(trustAllLocal && DQPWorkContext.getWorkContext().isLocal()))) {
throw new LoginException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40087));
}
} else {
userName = getUserName(subject, baseUserName);
}
securityContext = this.securityHelper.getSecurityContext();
} else {
userName = baseUserName;
securityContext = this.securityHelper.authenticate(securityDomain, baseUserName, credentials, applicationName);
subject = this.securityHelper.getSubjectInContext(securityContext);
}
} else {
LogManager.logDetail(LogConstants.CTX_SECURITY, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40117));
}
long creationTime = System.currentTimeMillis();
// Return a new session info object
SessionMetadata newSession = new SessionMetadata();
newSession.setSessionToken(new SessionToken(userName));
newSession.setSessionId(newSession.getSessionToken().getSessionID());
newSession.setUserName(userName);
newSession.setCreatedTime(creationTime);
newSession.setApplicationName(applicationName);
newSession.setClientHostName(hostName);
newSession.setIPAddress(ipAddress);
newSession.setClientHardwareAddress(clientMac);
newSession.setSecurityDomain(securityDomain);
if (vdb != null) {
newSession.setVDBName(vdb.getName());
newSession.setVDBVersion(vdb.getVersion());
}
// these are local no need for monitoring.
newSession.setSubject(subject);
newSession.setSecurityContext(securityContext);
newSession.setVdb(vdb);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_SECURITY, MessageLevel.DETAIL)) {
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] { "Logon successful, created", newSession });
}
this.sessionCache.put(newSession.getSessionId(), newSession);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// $NON-NLS-1$ //$NON-NLS-2$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, new AuditMessage("session", "logon-success", newSession));
}
return newSession;
} catch (LoginException e) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// $NON-NLS-1$ //$NON-NLS-2$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, new AuditMessage("session", "logon-fail", info, e));
}
throw e;
} catch (SessionServiceException e) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// $NON-NLS-1$ //$NON-NLS-2$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, new AuditMessage("session", "logon-fail", info, e));
}
throw e;
}
}
Aggregations