use of com.iplanet.services.ldap.ServerGroup in project OpenAM by OpenRock.
the class BootstrapCreator method getBootStrapURL.
/**
* Returns the bootstrap url.
*
* @param dsCfg instance of the <code>IDSConfigMgr</code> containing
* the connection information to the config store.
* @exception ConfigurationException if there is an error and cannot
* obtain the bootstrap URL. This may be due to connection error.
*/
public String getBootStrapURL(IDSConfigMgr dsCfg) throws ConfigurationException {
String bootstrapStr = null;
try {
ServerGroup sg = dsCfg.getServerGroup("sms");
ServerGroup defaultGroup = dsCfg.getServerGroup("default");
ServerInstance svrCfg;
if (sg == null) {
sg = defaultGroup;
svrCfg = dsCfg.getServerInstance(LDAPUser.Type.AUTH_ADMIN);
} else {
svrCfg = sg.getServerInstance(LDAPUser.Type.AUTH_ADMIN);
}
ServerInstance userInstance = defaultGroup.getServerInstance(LDAPUser.Type.AUTH_ADMIN);
String dsameUserName = userInstance.getAuthID();
String dsameUserPwd = JCECrypt.encode(userInstance.getPasswd());
String connDN = svrCfg.getAuthID();
String connPwd = JCECrypt.encode(svrCfg.getPasswd());
String rootSuffix = svrCfg.getBaseDN();
Collection serverList = sg.getServersList();
StringBuilder bootstrap = new StringBuilder();
for (Iterator i = serverList.iterator(); i.hasNext(); ) {
Server serverObj = (Server) i.next();
Server.Type connType = serverObj.getConnectionType();
String proto = (connType.equals(Server.Type.CONN_SIMPLE)) ? "ldap" : "ldaps";
String url = StringUtils.strReplaceAll(template, "@DS_PROTO@", proto);
String host = serverObj.getServerName() + ":" + serverObj.getPort();
url = StringUtils.strReplaceAll(url, "@DS_HOST@", host);
url = StringUtils.strReplaceAll(url, "@INSTANCE_NAME@", URLEncoder.encode(SystemProperties.getServerInstanceName(), "UTF-8"));
url = StringUtils.strReplaceAll(url, "@DSAMEUSER_NAME@", URLEncoder.encode(dsameUserName, "UTF-8"));
url = StringUtils.strReplaceAll(url, "@DSAMEUSER_PWD@", URLEncoder.encode(dsameUserPwd, "UTF-8"));
url = StringUtils.strReplaceAll(url, "@BASE_DN@", URLEncoder.encode(rootSuffix, "UTF-8"));
url = StringUtils.strReplaceAll(url, "@BIND_DN@", URLEncoder.encode(connDN, "UTF-8"));
url = StringUtils.strReplaceAll(url, "@BIND_PWD@", URLEncoder.encode(connPwd, "UTF-8"));
bootstrap.append(url).append("\n");
}
bootstrapStr = bootstrap.toString();
} catch (IOException e) {
throw new ConfigurationException(e.getMessage());
}
return bootstrapStr;
}
use of com.iplanet.services.ldap.ServerGroup in project OpenAM by OpenRock.
the class Agent method federationConfig.
public static int federationConfig(SSOServerRealmFedInfo srfi) {
String classMethod = "Agent.federationConfig:";
Date startDate = new Date();
String realm = srfi.realmName;
Integer ri = getRealmIndexFromName(realm);
Set<String> cots = srfi.cots;
Map<String, Map<String, String>> saml2Ents = srfi.samlv2Ents;
Map<String, Map<String, String>> wsEnts = srfi.wsEnts;
Map<String, Map<String, String>> idffEnts = srfi.idffEnts;
Map<String, Map<String, Set<String>>> cotMembs = srfi.membEnts;
StringBuilder sb = new StringBuilder(classMethod);
if (debug.messageEnabled()) {
sb.append("fed entities for realm ").append(realm).append(":\n");
sb.append(" Circle of Trusts set has ");
}
if (server == null) {
// can't do anything without a server
debug.error(classMethod + "no server");
return -1;
}
SsoServerFedCOTs ssfc = getFedCOTsMBean();
if ((cots != null) && (cots.size() > 0)) {
if (debug.messageEnabled()) {
sb.append(cots.size()).append(" entries:\n");
}
TableSsoServerFedCOTsTable ftab = null;
try {
ftab = ssfc.accessSsoServerFedCOTsTable();
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting fed COTs table: ", ex);
}
if (ftab != null) {
int i = 1;
for (String ss : cots) {
ss = getEscapedString(ss);
if (debug.messageEnabled()) {
sb.append(" #").append(i).append(": ").append(ss).append("\n");
}
SsoServerFedCOTsEntryImpl cei = new SsoServerFedCOTsEntryImpl(sunMib);
cei.SsoServerRealmIndex = ri;
cei.FedCOTName = ss;
cei.FedCOTIndex = new Integer(i++);
ObjectName oname = cei.createSsoServerFedCOTsEntryObjectName(server);
if (oname == null) {
debug.error(classMethod + "Error creating object for Fed COT '" + ss + "'");
continue;
}
try {
ftab.addEntry(cei, oname);
if (cei != null) {
server.registerMBean(cei, oname);
}
} catch (JMException ex) {
debug.error(classMethod + ss, ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + ss, ex);
}
}
} else {
if (debug.messageEnabled()) {
sb.append("no entries\n");
}
}
}
/*
* the federation entities all go into the
* SsoServerFedEntitiesTable
*/
SsoServerFedEntities ssfe = getFedEntsMBean();
TableSsoServerFedEntitiesTable ftab = null;
try {
ftab = ssfe.accessSsoServerFedEntitiesTable();
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting FederationEntities table: ", ex);
// can't proceed without the table
return -1;
}
if (ftab != null) {
/*
* the SAML2 entities map:
* entity name -> hashmap of:
* key="location"; value="hosted" or "remote"
* key="roles"; value=some combo of IDP;SP
*/
// increments for all entries
int tabinx = 1;
if (debug.messageEnabled()) {
sb.append("\n SAML2 entities map has ");
}
if ((saml2Ents != null) && (saml2Ents.size() > 0)) {
TableSsoServerSAML2IDPTable iTab = null;
TableSsoServerSAML2SPTable sTab = null;
SsoServerSAML2SvcImpl ss2s = getSaml2SvcMBean();
try {
iTab = ss2s.accessSsoServerSAML2IDPTable();
sTab = ss2s.accessSsoServerSAML2SPTable();
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting SAML2 IDP and/or SP tables: ", ex);
// can't proceed without the tables
return -1;
}
if (debug.messageEnabled()) {
sb.append(saml2Ents.size()).append(" entries:\n");
}
Set ks = saml2Ents.keySet();
int idpi = 1;
int spi = 1;
for (Map.Entry<String, Map<String, String>> entry : saml2Ents.entrySet()) {
String entname = entry.getKey();
Map<String, String> hm = entry.getValue();
String loc = hm.get("location");
String roles = hm.get("roles");
SsoServerFedEntitiesEntryImpl cei = new SsoServerFedEntitiesEntryImpl(sunMib);
cei.SsoServerRealmIndex = ri;
cei.FedEntityName = getEscapedString(entname);
cei.FedEntityIndex = new Integer(tabinx++);
cei.FedEntityProto = "SAMLv2";
cei.FedEntityType = roles;
cei.FedEntityLoc = loc;
ObjectName oname = cei.createSsoServerFedEntitiesEntryObjectName(server);
if (oname == null) {
debug.error(classMethod + "Error creating object for SAML2 Entity '" + entname + "'");
continue;
}
try {
ftab.addEntry(cei, oname);
if (cei != null) {
server.registerMBean(cei, oname);
}
} catch (JMException ex) {
debug.error(classMethod + "JMEx adding SAMLv2 entity " + entname + " in realm " + realm, ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + "SnmpEx adding SAMLv2 entity " + entname + " in realm " + realm, ex);
}
/*
* these also need to be added to either (possibly
* both if in both roles?) SAML2's IDP or SP table
*/
if (((roles.indexOf("IDP")) >= 0) && loc.equalsIgnoreCase("hosted")) {
if (iTab == null) {
continue;
}
SsoServerSAML2IDPEntryImpl sei = new SsoServerSAML2IDPEntryImpl(sunMib);
sei.SAML2IDPArtifactsIssued = 0L;
sei.SAML2IDPAssertionsIssued = 0L;
sei.SAML2IDPInvalRqtsRcvd = 0L;
sei.SAML2IDPRqtsRcvd = 0L;
sei.SAML2IDPArtifactsInCache = 0L;
sei.SAML2IDPAssertionsInCache = 0L;
sei.SAML2IDPIndex = new Integer(idpi++);
sei.SAML2IDPName = getEscapedString(entname);
sei.SsoServerRealmIndex = ri;
oname = sei.createSsoServerSAML2IDPEntryObjectName(server);
ss2s.incHostedIDPCount();
try {
iTab.addEntry(sei, oname);
if (sei != null) {
server.registerMBean(sei, oname);
}
/* is a Map of realm/saml2idp to index needed? */
String rai = realm + "|" + entname;
// sei is this bean's instance
realmSAML2IDPs.put(rai, sei);
} catch (JMException ex) {
debug.error(classMethod + "JMEx adding SAMLv2 IDP entity " + entname + " in realm " + realm, ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + "SnmpEx adding SAMLv2 IDP entity " + entname + " in realm " + realm, ex);
}
}
if (((roles.indexOf("IDP")) >= 0) && loc.equalsIgnoreCase("remote")) {
ss2s.incRemoteIDPCount();
}
if (((roles.indexOf("SP")) >= 0) && loc.equalsIgnoreCase("hosted")) {
if (sTab == null) {
continue;
}
SsoServerSAML2SPEntryImpl sei = new SsoServerSAML2SPEntryImpl(sunMib);
sei.SAML2SPInvalidArtifactsRcvd = 0L;
sei.SAML2SPValidAssertionsRcvd = 0L;
sei.SAML2SPRqtsSent = 0L;
sei.SAML2SPName = getEscapedString(entname);
sei.SsoServerRealmIndex = ri;
sei.SAML2SPIndex = new Integer(spi++);
oname = sei.createSsoServerSAML2SPEntryObjectName(server);
try {
sTab.addEntry(sei, oname);
if (sei != null) {
server.registerMBean(sei, oname);
}
/* is a Map of realm/saml2sp to index needed? */
String rai = realm + "|" + entname;
// sei is this bean's instance
realmSAML2SPs.put(rai, sei);
} catch (JMException ex) {
debug.error(classMethod + "JMEx adding SAMLv2 SP entity " + entname + " in realm " + realm, ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + "SnmpEx adding SAMLv2 SP entity " + entname + " in realm " + realm, ex);
}
}
if (debug.messageEnabled()) {
sb.append(" name=").append(entname).append(", loc=").append(loc).append(", roles=").append(roles).append("\n");
}
}
} else {
if (debug.messageEnabled()) {
sb.append("no entries\n");
}
}
/*
* the WSFed entities map:
* entity name -> hashmap of:
* key="location"; value="hosted" or "remote"
* key="roles"; value=some combo of IDP;SP
*/
if (debug.messageEnabled()) {
sb.append("\n WSFed entities map has ");
}
if ((wsEnts != null) && (wsEnts.size() > 0)) {
if (debug.messageEnabled()) {
sb.append(wsEnts.size()).append(" entries:\n");
}
for (Map.Entry<String, Map<String, String>> entry : wsEnts.entrySet()) {
String entname = entry.getKey();
Map<String, String> hm = entry.getValue();
String loc = hm.get("location");
String roles = hm.get("roles");
SsoServerFedEntitiesEntryImpl cei = new SsoServerFedEntitiesEntryImpl(sunMib);
cei.SsoServerRealmIndex = ri;
cei.FedEntityName = getEscapedString(entname);
cei.FedEntityIndex = new Integer(tabinx++);
cei.FedEntityProto = "WSFed";
cei.FedEntityType = roles;
cei.FedEntityLoc = loc;
ObjectName oname = cei.createSsoServerFedEntitiesEntryObjectName(server);
if (oname == null) {
debug.error(classMethod + "Error creating object for WSFed Entity '" + entname + "'");
continue;
}
try {
ftab.addEntry(cei, oname);
if (cei != null) {
server.registerMBean(cei, oname);
}
} catch (JMException ex) {
debug.error(classMethod + "JMEx adding WSFed entity " + entname + " in realm " + realm, ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + "SnmpEx adding WSFed entity " + entname + " in realm " + realm, ex);
}
sb.append(" name=").append(entname).append(", loc=").append(loc).append(", roles=").append(roles).append("\n");
}
} else {
if (debug.messageEnabled()) {
sb.append("no entries\n");
}
}
/*
* the IDFF entities map:
* entity name -> hashmap of:
* key="location"; value="hosted" or "remote"
* key="roles"; value=some combo of IDP;SP
*/
if (debug.messageEnabled()) {
sb.append("\n IDFF entities map has ");
}
if ((idffEnts != null) && (idffEnts.size() > 0)) {
if (debug.messageEnabled()) {
sb.append(idffEnts.size()).append(" entries:\n");
}
for (Map.Entry<String, Map<String, String>> entry : idffEnts.entrySet()) {
String entname = entry.getKey();
Map<String, String> hm = entry.getValue();
String loc = hm.get("location");
String roles = hm.get("roles");
SsoServerFedEntitiesEntryImpl cei = new SsoServerFedEntitiesEntryImpl(sunMib);
cei.SsoServerRealmIndex = ri;
cei.FedEntityName = getEscapedString(entname);
cei.FedEntityIndex = new Integer(tabinx++);
cei.FedEntityProto = "IDFF";
cei.FedEntityType = roles;
cei.FedEntityLoc = loc;
ObjectName oname = cei.createSsoServerFedEntitiesEntryObjectName(server);
if (oname == null) {
debug.error(classMethod + "Error creating object for IDFF Entity '" + entname + "'");
continue;
}
try {
ftab.addEntry(cei, oname);
if (cei != null) {
server.registerMBean(cei, oname);
}
} catch (JMException ex) {
debug.error(classMethod + "JMEx adding IDFF entity " + entname + " in realm " + realm, ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + "SnmpEx adding IDFF entity " + entname + " in realm " + realm, ex);
}
if (debug.messageEnabled()) {
sb.append(" name=").append(entname).append(", loc=").append(loc).append(", roles=").append(roles).append("\n");
}
}
} else {
if (debug.messageEnabled()) {
sb.append("no entries\n");
}
}
} else {
debug.error(classMethod + "FederationEntities table is null");
}
/*
* the COT members map:
* cot name -> hashmap of:
* key="SAML"; value=Set of member names
* key="IDFF"; value=Set of member names
* key="WSFed"; value=Set of member names
*/
if (debug.messageEnabled()) {
sb.append("\n COT Members map has ");
}
if ((cotMembs != null) && (cotMembs.size() > 0)) {
if (debug.messageEnabled()) {
sb.append(cotMembs.size()).append(" entries:\n");
}
int coti = 1;
TableSsoServerFedCOTMemberTable mtab = null;
try {
mtab = ssfc.accessSsoServerFedCOTMemberTable();
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting fed COT members table: ", ex);
}
for (Map.Entry<String, Map<String, Set<String>>> entry : cotMembs.entrySet()) {
String cotname = entry.getKey();
Map<String, Set<String>> hm = entry.getValue();
cotname = getEscapedString(cotname);
if (debug.messageEnabled()) {
sb.append(" COT name = ").append(cotname).append(", SAML members = ");
}
Set<String> fset = hm.get("SAML");
int mi = 1;
Integer cotI = new Integer(coti++);
if ((fset != null) && fset.size() > 0) {
for (String mbm : fset) {
if (debug.messageEnabled()) {
sb.append(" ").append(mbm).append("\n");
}
SsoServerFedCOTMemberEntryImpl cmi = new SsoServerFedCOTMemberEntryImpl(sunMib);
cmi.FedCOTMemberType = "SAMLv2";
cmi.FedCOTMemberName = getEscapedString(mbm);
cmi.FedCOTMemberIndex = new Integer(mi++);
cmi.SsoServerRealmIndex = ri;
// xxx - need to get from tbl
cmi.FedCOTIndex = cotI;
ObjectName ceName = cmi.createSsoServerFedCOTMemberEntryObjectName(server);
if (ceName == null) {
debug.error(classMethod + "Error creating object for SAMLv2 COT Member '" + mbm + "'");
continue;
}
try {
mtab.addEntry(cmi, ceName);
if (ceName != null) {
server.registerMBean(cmi, ceName);
}
} catch (Exception ex) {
debug.error(classMethod + "cotmember = " + mbm, ex);
}
}
} else {
if (debug.messageEnabled()) {
sb.append(" NONE\n");
}
}
fset = hm.get("IDFF");
if (debug.messageEnabled()) {
sb.append(" IDFF members = ");
}
if ((fset != null) && fset.size() > 0) {
for (String mbm : fset) {
if (debug.messageEnabled()) {
sb.append(" ").append(mbm).append("\n");
}
SsoServerFedCOTMemberEntryImpl cmi = new SsoServerFedCOTMemberEntryImpl(sunMib);
cmi.FedCOTMemberType = "IDFF";
cmi.FedCOTMemberName = getEscapedString(mbm);
cmi.FedCOTMemberIndex = new Integer(mi++);
cmi.SsoServerRealmIndex = ri;
// xxx - need to get from tbl
cmi.FedCOTIndex = cotI;
ObjectName ceName = cmi.createSsoServerFedCOTMemberEntryObjectName(server);
if (ceName == null) {
debug.error(classMethod + "Error creating object for IDFF COT Member '" + mbm + "'");
continue;
}
try {
mtab.addEntry(cmi, ceName);
if (ceName != null) {
server.registerMBean(cmi, ceName);
}
} catch (Exception ex) {
debug.error(classMethod + "cotmember = " + mbm, ex);
}
}
} else {
if (debug.messageEnabled()) {
sb.append(" NONE\n");
}
}
fset = hm.get("WSFed");
if (debug.messageEnabled()) {
sb.append(" WSFed members = ");
}
if ((fset != null) && fset.size() > 0) {
for (String mbm : fset) {
if (debug.messageEnabled()) {
sb.append(" ").append(mbm).append("\n");
}
SsoServerFedCOTMemberEntryImpl cmi = new SsoServerFedCOTMemberEntryImpl(sunMib);
cmi.FedCOTMemberType = "WSFed";
cmi.FedCOTMemberName = getEscapedString(mbm);
cmi.FedCOTMemberIndex = new Integer(mi++);
cmi.SsoServerRealmIndex = ri;
// xxx - need to get from tbl
cmi.FedCOTIndex = cotI;
ObjectName ceName = cmi.createSsoServerFedCOTMemberEntryObjectName(server);
if (ceName == null) {
debug.error(classMethod + "Error creating object for WSFed Member '" + mbm + "'");
continue;
}
try {
mtab.addEntry(cmi, ceName);
if (ceName != null) {
server.registerMBean(cmi, ceName);
}
} catch (Exception ex) {
debug.error(classMethod + "cotmember = " + mbm, ex);
}
}
} else {
if (debug.messageEnabled()) {
sb.append(" NONE\n");
}
}
}
}
if (debug.messageEnabled()) {
debug.message(sb.toString());
}
/*
* have to do it here?
*/
if (debug.messageEnabled()) {
try {
DSConfigMgr dscm = DSConfigMgr.getDSConfigMgr();
ServerGroup sgrp = dscm.getServerGroup("sms");
Collection<Server> slist = sgrp.getServersList();
StringBuilder sbp1 = new StringBuilder("DSConfigMgr:\n");
for (Server sobj : slist) {
String svr = sobj.getServerName();
int port = sobj.getPort();
sbp1.append(" svrname = ").append(svr).append(", port = ").append(port).append("\n");
}
debug.message(classMethod + sbp1.toString());
} catch (Exception d) {
debug.message(classMethod + "trying to get Directory Server Config");
}
Properties props = SystemProperties.getProperties();
StringBuilder sbp = new StringBuilder("SYSPROPS:\n");
for (Map.Entry<Object, Object> entry : props.entrySet()) {
String entname = (String) entry.getKey();
String val = (String) entry.getValue();
sbp.append(" key = ").append(entname).append(", val = ").append(val).append("\n");
}
debug.message(classMethod + sbp.toString());
String dirHost = SystemProperties.get(Constants.AM_DIRECTORY_HOST);
String dirPort = SystemProperties.get(Constants.AM_DIRECTORY_PORT);
String drSSL = SystemProperties.get(Constants.AM_DIRECTORY_SSL_ENABLED);
boolean dirSSL = SystemProperties.getAsBoolean(Constants.AM_DIRECTORY_SSL_ENABLED);
debug.message(classMethod + "SMS CONFIG:\n host = " + dirHost + "\n port = " + dirPort + "\n ssl = " + drSSL + "\n dirSSL = " + dirSSL);
Date stopDate = new Date();
String stDate = sdf.format(startDate);
String endDate = sdf.format(stopDate);
debug.message("Agent.federationConfig:\n Start Time = " + stDate + "\n End Time = " + endDate);
}
return 0;
}
use of com.iplanet.services.ldap.ServerGroup in project OpenAM by OpenRock.
the class SMDataLayer method initLdapPool.
/**
* Initialize the pool shared by all SMDataLayer object(s).
*/
private synchronized void initLdapPool() {
// Dont' do anything if pool is already initialized
if (_ldapPool != null)
return;
// Initialize the pool with minimum and maximum connections settings
// retrieved from configuration
ServerInstance svrCfg;
try {
DSConfigMgr dsCfg = DSConfigMgr.getDSConfigMgr();
// Get "sms" ServerGroup if present
ServerGroup sg = dsCfg.getServerGroup("sms");
final ConnectionFactory baseFactory;
if (sg != null) {
baseFactory = dsCfg.getNewConnectionFactory("sms", LDAPUser.Type.AUTH_ADMIN);
svrCfg = sg.getServerInstance(LDAPUser.Type.AUTH_ADMIN);
} else {
baseFactory = dsCfg.getNewAdminConnectionFactory();
svrCfg = dsCfg.getServerInstance(LDAPUser.Type.AUTH_ADMIN);
}
if (svrCfg == null) {
debug.error("SMDataLayer:initLdapPool()-" + "Error getting server config.");
}
int poolMin = 1;
int poolMax = 2;
// Initialize the Connection Pool size only for the server
if (SystemProperties.isServerMode()) {
poolMin = svrCfg.getMinConnections();
poolMax = svrCfg.getMaxConnections();
}
debug.message("SMDataLayer:initLdapPool(): Creating ldap connection pool with: poolMin {} poolMax {}", poolMin, poolMax);
int idleTimeout = SystemProperties.getAsInt(LDAP_CONN_IDLE_TIME_IN_SECS, 0);
if (idleTimeout == 0 && StringUtils.isNotBlank(SystemProperties.get(LDAP_CONN_IDLE_TIME_IN_SECS))) {
debug.error("SMDataLayer: Idle timeout could not be parsed, connection reaping is disabled");
} else if (idleTimeout == 0) {
debug.message("SMDataLayer: Idle timeout is set to 0 - connection reaping is disabled");
}
_ldapPool = Connections.newCachedConnectionPool(baseFactory, poolMin, poolMax, idleTimeout, TimeUnit.SECONDS);
ShutdownManager shutdownMan = com.sun.identity.common.ShutdownManager.getInstance();
shutdownMan.addShutdownListener(new ShutdownListener() {
public void shutdown() {
if (_ldapPool != null) {
_ldapPool.close();
}
}
});
} catch (LDAPServiceException ex) {
debug.error("SMDataLayer:initLdapPool()-" + "Error initializing connection pool " + ex.getMessage());
ex.printStackTrace();
}
}
use of com.iplanet.services.ldap.ServerGroup in project OpenAM by OpenRock.
the class ServerGroupConfigurationTest method shouldReturnPasswordFromInstance.
@Test
public void shouldReturnPasswordFromInstance() {
// Given
ServerInstance mockInstance = mock(ServerInstance.class);
ServerGroup mockGroup = mock(ServerGroup.class);
ServerGroupConfiguration config = new ServerGroupConfiguration(mockGroup, mockInstance);
given(mockInstance.getPasswd()).willReturn("");
// When
config.getBindPassword();
// Then
verify(mockInstance).getPasswd();
}
use of com.iplanet.services.ldap.ServerGroup in project OpenAM by OpenRock.
the class ServerGroupConfigurationTest method shouldReturnCorrectLDAPURLforSSLConnections.
@Test
public void shouldReturnCorrectLDAPURLforSSLConnections() {
// Given
String hostName = "localhost";
int port = 389;
Server one = mock(Server.class);
given(one.getServerName()).willReturn(hostName);
given(one.getPort()).willReturn(port);
given(one.getConnectionType()).willReturn(Server.Type.CONN_SSL);
ServerInstance mockInstance = mock(ServerInstance.class);
ServerGroup mockGroup = mock(ServerGroup.class);
given(mockGroup.getServersList()).willReturn(Arrays.asList(one));
ServerGroupConfiguration config = new ServerGroupConfiguration(mockGroup, mockInstance);
// When
Set<LDAPURL> result = config.getLDAPURLs();
// Then
assertThat(result).hasSize(1);
LDAPURL url = result.iterator().next();
assertThat(url.getHost()).isEqualTo(hostName);
assertThat(url.getPort()).isEqualTo(port);
assertThat(url.isSSL()).isTrue();
}
Aggregations