Search in sources :

Example 1 with Version

use of org.teiid.dqp.internal.process.DQPWorkContext.Version in project teiid by teiid.

the class LogonImpl method logon.

public LogonResult logon(Properties connProps) throws LogonException {
    String vdbName = connProps.getProperty(BaseDataSource.VDB_NAME);
    String vdbVersion = connProps.getProperty(BaseDataSource.VDB_VERSION);
    String user = connProps.getProperty(TeiidURL.CONNECTION.USER_NAME, CoreConstants.DEFAULT_ANON_USERNAME);
    boolean onlyAllowPassthrough = Boolean.valueOf(connProps.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, // $NON-NLS-1$
    "false"));
    AuthenticationType authType = AuthenticationType.USERPASSWORD;
    if (!onlyAllowPassthrough) {
        authType = this.service.getAuthenticationType(vdbName, vdbVersion, user);
    }
    // the presence of the KRB5 token take as GSS based login.
    if (connProps.get(ILogon.KRB5TOKEN) != null) {
        if (authType == AuthenticationType.GSS) {
            Object previous = null;
            boolean assosiated = false;
            SecurityHelper securityHelper = service.getSecurityHelper();
            try {
                byte[] krb5Token = (byte[]) connProps.get(ILogon.KRB5TOKEN);
                Object securityContext = this.gssServiceTickets.remove(Base64.encodeBytes(MD5(krb5Token)));
                if (securityContext == null) {
                    throw new LogonException(RuntimePlugin.Event.TEIID40054, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40054));
                }
                previous = securityHelper.associateSecurityContext(securityContext);
                assosiated = true;
                return logon(connProps, krb5Token, AuthenticationType.GSS, user);
            } finally {
                if (assosiated) {
                    securityHelper.associateSecurityContext(previous);
                }
            }
        } else {
        // shouldn't really get here, but we'll try user name password anyway
        }
    } else if (authType == AuthenticationType.GSS) {
        Version v = DQPWorkContext.getWorkContext().getClientVersion();
        // send a login result with a GSS challange
        if (v.compareTo(Version.EIGHT_7) >= 0) {
            LogonResult result = new LogonResult();
            result.addProperty(ILogon.AUTH_TYPE, authType);
            return result;
        }
        // throw an exception
        throw new LogonException(RuntimePlugin.Event.TEIID40149, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40149));
    }
    if (!AuthenticationType.USERPASSWORD.equals(authType)) {
        throw new LogonException(RuntimePlugin.Event.TEIID40055, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40055, authType));
    }
    return logon(connProps, null, AuthenticationType.USERPASSWORD, user);
}
Also used : Version(org.teiid.dqp.internal.process.DQPWorkContext.Version) LogonException(org.teiid.client.security.LogonException) LogonResult(org.teiid.client.security.LogonResult) AuthenticationType(org.teiid.net.socket.AuthenticationType) SecurityHelper(org.teiid.security.SecurityHelper)

Aggregations

LogonException (org.teiid.client.security.LogonException)1 LogonResult (org.teiid.client.security.LogonResult)1 Version (org.teiid.dqp.internal.process.DQPWorkContext.Version)1 AuthenticationType (org.teiid.net.socket.AuthenticationType)1 SecurityHelper (org.teiid.security.SecurityHelper)1