Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified WinRM classes to work with IBM JDK #130

Merged
merged 2 commits into from
Oct 17, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/main/java/com/xebialabs/overthere/cifs/winrm/JavaVendor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2008-2014, XebiaLabs B.V., All rights reserved.
*
*
* Overthere is licensed under the terms of the GPLv2
* <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most XebiaLabs Libraries.
* There are special exceptions to the terms and conditions of the GPLv2 as it is applied to
* this software, see the FLOSS License Exception
* <http://github.com/xebialabs/overthere/blob/master/LICENSE>.
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; version 2
* of the License.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
package com.xebialabs.overthere.cifs.winrm;

import java.util.HashMap;
import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.Configuration;

class JavaVendor {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] Rename this to SystemConfig or so? I can imagine we'll need to get other type of system-level data. I guess the method would then be called isIbmJdk or so...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's first see what all ends up in here, ie. the other methods which switch on the isIBM, see below


private static final boolean IBM_JAVA = System.getProperty("java.vendor").contains("IBM");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor about this one...do we know whether IBM here is always uppercase?

Also some minor style issues in this class: spacing and indents.


public static boolean isIBM() {
return IBM_JAVA;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,27 @@ class KerberosJaasConfiguration extends Configuration {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
final HashMap<String, String> options = new HashMap<String, String>();
options.put("client", "true");
options.put("useTicketCache", "false");
options.put("useKeyTab", "false");
options.put("doNotPrompt", "false");
options.put("refreshKrb5Config", "true");
if (debug) {
options.put("debug", "true");

if (JavaVendor.isIBM()) {
options.put("refreshKrb5Config", "true");
} else {
options.put("client", "true");
options.put("useTicketCache", "false");
options.put("useKeyTab", "false");
options.put("doNotPrompt", "false");
options.put("refreshKrb5Config", "true");
if (debug) {
options.put("debug", "true");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are none of these options supported on the IBM JDK? If so, does this need to be documented somewhere?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me first say I'm really not an expert on this..
I based my work on this page:
https://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzaha/rzahajgssusejaas20.htm

I could have added useCcache and useKeyTab, but they are false by default so I figured it wasn't necessary. I'll try to add credsType=initiator, I guess that equals the client=true option for Oracle JDK.
I've been trying to google more info about this, and see that the debug option is in fact used by others. So I'll try to add that as well.

}
return new AppConfigurationEntry[]{new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule",

return new AppConfigurationEntry[]{new AppConfigurationEntry(getKrb5LoginModuleName(),
AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options)};
}

private String getKrb5LoginModuleName() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] Can be static?

return (JavaVendor.isIBM() ? "com.ibm.security.auth.module.Krb5LoginModule"
: "com.sun.security.auth.module.Krb5LoginModule");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ protected byte[] generateGSSToken(final byte[] input, final Oid oid, String auth
GSSName canonicalizedName = serverName.canonicalize(oid);

logger.debug("Creating SPNego GSS context for canonicalized SPN {}", canonicalizedName);
GSSContext gssContext = manager.createContext(canonicalizedName, oid, null, GSSContext.DEFAULT_LIFETIME);
// With IBM JDK we need to use GSSContext.INDEFINITE_LIFETIME for SPNEGO
// ref http://www-01.ibm.com/support/docview.wss?uid=swg1IZ54545
int spnegoLifetime = (JavaVendor.isIBM() ? GSSContext.INDEFINITE_LIFETIME : GSSContext.DEFAULT_LIFETIME);
GSSContext gssContext = manager.createContext(canonicalizedName, oid, null, spnegoLifetime);
gssContext.requestMutualAuth(true);
gssContext.requestCredDeleg(true);
return gssContext.initSecContext(token, 0, token.length);
Expand Down