Hashtable<String, String> environment = new Hashtable<String, String>();
environment.put(Context.INITIAL_CONTEXT_FACTORY, getResources().getInitialCtxFactory());
environment.put(Context.URL_PKG_PREFIXES, getResources().getUrlPkgPrefixes());
environment.put(Context.PROVIDER_URL, getResources().getProviderUrl());
remoteContext = new InitialContext(environment);
AuthenticationService service = getService(AuthenticationServiceHome.JNDI_NAME, AuthenticationServiceHome.class);
if (SyncResources.LOGIN_MODE_LOGIN_PASSWORD.equals(getResources().getLoginMode())) {
subject = service.authenticate(getResources().getLogin(), getResources().getPassword());
} else {
GSSManager manager = GSSManager.getInstance();
GSSCredential clientCred = manager.createCredential(GSSCredential.INITIATE_ONLY);
GSSName peerName = manager.createName("WFServer", null);
GSSContext context = manager.createContext(peerName, (Oid) null, clientCred, GSSContext.DEFAULT_LIFETIME);
context.requestMutualAuth(false);
byte[] token = new byte[0];
token = context.initSecContext(token, 0, token.length);
subject = service.authenticate(token);
}
}