/** * Construct with prepared KrbConfig. * @param krbConfig The krb config */ public KrbClientBase(KrbConfig krbConfig) { this.krbConfig = krbConfig; this.commonOptions = new KOptions(); this.krbSetting = new KrbSetting(commonOptions, krbConfig); }
/** * Fix principal name. * * @param principal The principal name * @return The fixed principal */ protected String fixPrincipal(String principal) { if (!principal.contains("@")) { principal += "@" + krbSetting.getKdcRealm(); } return principal; } }
/** * Get krbconfig. * @return The krb config */ public KrbConfig getConfig() { return krbSetting.getKrbConfig(); }
/** * Check kdc udp setting and see if any bad. * @return valid udp port or -1 if not allowUdp * @throws KrbException e */ public int checkGetKdcUdpPort() throws KrbException { if (allowUdp()) { int kdcPort = getKdcUdpPort(); if (kdcPort < 1) { throw new KrbException("KDC udp port isn't set or configured"); } return kdcPort; } return -1; }
/** * Check kdc tcp setting and see if any bad. * @return valid tcp port or -1 if not allowTcp * @throws KrbException e */ public int checkGetKdcTcpPort() throws KrbException { if (allowTcp()) { int kdcPort = getKdcTcpPort(); if (kdcPort < 1) { throw new KrbException("KDC tcp port isn't set or configured"); } return kdcPort; } return -1; }
/** * Returns a list of KDC * * @throws KrbException if there's no way to find KDC for the realm * @return the list of KDC, always non null */ public static List<String> getKDCList(String realm, KrbSetting krbSetting) throws KrbException { List<String> kdcList = new ArrayList<>(); if (realm != null) { KrbConfig krbConfig = krbSetting.getKrbConfig(); List<Object> kdcs = krbConfig.getRealmSectionItems(realm, "kdc"); if (!kdcs.isEmpty()) { for (Object object : kdcs) { kdcList.add(object != null ? object.toString() : null); } } if (kdcList.isEmpty()) { LOG.warn("Cannot get kdc for realm " + realm); kdcList.add(krbSetting.getKdcHost()); } } else { throw new KrbException("Can't get the realm"); } return kdcList; } }
body.setSname(sName); String realm = getContext().getKrbSetting().getKdcRealm(); if (sName != null && sName.getRealm() != null) { realm = sName.getRealm(); renewLifetime = getRequestOptions().getIntegerOption(KrbOption.RENEWABLE_TIME); } else { String renewLifetimeStr = getContext().getKrbSetting().getKrbConfig().getRenewLifetime(); renewLifetime = KOptions.parseDuration(renewLifetimeStr);
KrbSetting setting, String kdcString) throws KrbException, IOException { TransportPair result = new TransportPair(); int tcpPort = setting.checkGetKdcTcpPort(); int udpPort = setting.checkGetKdcUdpPort();
body.setSname(sName); String realm = getContext().getKrbSetting().getKdcRealm(); if (sName != null && sName.getRealm() != null) { realm = sName.getRealm(); renewLifetime = getRequestOptions().getIntegerOption(KrbOption.RENEWABLE_TIME); } else { String renewLifetimeStr = getContext().getKrbSetting().getKrbConfig().getRenewLifetime(); renewLifetime = KOptions.parseDuration(renewLifetimeStr);
/** * Returns a list of KDC * * @throws KrbException if there's no way to find KDC for the realm * @return the list of KDC, always non null */ public static List<String> getKDCList(String realm, KrbSetting krbSetting) throws KrbException { List<String> kdcList = new ArrayList<>(); if (realm != null) { KrbConfig krbConfig = krbSetting.getKrbConfig(); List<Object> kdcs = krbConfig.getRealmSectionItems(realm, "kdc"); if (!kdcs.isEmpty()) { for (Object object : kdcs) { kdcList.add(object != null ? object.toString() : null); } } if (kdcList.isEmpty()) { LOG.warn("Cannot get kdc for realm " + realm); kdcList.add(krbSetting.getKdcHost()); } } else { throw new KrbException("Can't get the realm"); } return kdcList; } }
/** * Check kdc udp setting and see if any bad. * @return valid udp port or -1 if not allowUdp * @throws KrbException e */ public int checkGetKdcUdpPort() throws KrbException { if (allowUdp()) { int kdcPort = getKdcUdpPort(); if (kdcPort < 1) { throw new KrbException("KDC udp port isn't set or configured"); } return kdcPort; } return -1; }
/** * Check kdc tcp setting and see if any bad. * @return valid tcp port or -1 if not allowTcp * @throws KrbException e */ public int checkGetKdcTcpPort() throws KrbException { if (allowTcp()) { int kdcPort = getKdcTcpPort(); if (kdcPort < 1) { throw new KrbException("KDC tcp port isn't set or configured"); } return kdcPort; } return -1; }
KrbSetting setting, String kdcString) throws KrbException, IOException { TransportPair result = new TransportPair(); int tcpPort = setting.checkGetKdcTcpPort(); int udpPort = setting.checkGetKdcUdpPort();
/** * Fix principal name. * * @param principal The principal name * @return The fixed principal */ protected String fixPrincipal(String principal) { if (!principal.contains("@")) { principal += "@" + krbSetting.getKdcRealm(); } return principal; } }
/** * Construct with prepared KrbConfig. * @param krbConfig The krb config */ public KrbClientBase(KrbConfig krbConfig) { this.krbConfig = krbConfig; this.commonOptions = new KOptions(); this.krbSetting = new KrbSetting(commonOptions, krbConfig); }
/** * Get krbconfig. * @return The krb config */ public KrbConfig getConfig() { return krbSetting.getKrbConfig(); }
private PrincipalName makeTgsPrincipal() { return KrbUtil.makeTgsPrincipal(getContext().getKrbSetting().getKdcRealm()); }
/** * Default constructor. * @throws KrbException e */ public KrbClientBase() throws KrbException { this.krbConfig = ClientUtil.getDefaultConfig(); this.commonOptions = new KOptions(); this.krbSetting = new KrbSetting(commonOptions, krbConfig); }
final String ccacheNameConf = krbClient.getSetting().getKrbConfig().getString("default_ccache_name"); String ccacheName; if (ccacheNameEnv != null) {
private PrincipalName getServerPrincipal() { return KrbUtil.makeTgsPrincipal(getKrbContext().getKrbSetting().getKdcRealm()); }