use of com.sun.management.snmp.SnmpStatusException in project OpenAM by OpenRock.
the class Agent method configAgentGroups.
/**
* process realm's Agent Groups
*
* the HashMap of attributes/values:
* CLIConstants.ATTR_NAME_AGENT_TYPE
* type is extracted from the set; can be:
* WebAgent
* J2EEAgent
* don't do "SharedAgent" (authenticators)
* WebAgent should have:
* "com.sun.identity.agents.config.agenturi.prefix"
* "com.sun.identity.agents.config.login.url"
* J2EEAgents should have:
* "com.sun.identity.agents.config.login.url"
* "com.sun.identity.client.notification.url"
* 2.2_Agent
* no groups
*/
public static void configAgentGroups(String realm, Map<String, Map<String, String>> agtAttrs) {
String classMethod = "Agent.configAgentGroups:";
if ((agtAttrs == null) || agtAttrs.isEmpty()) {
if (debug.messageEnabled()) {
debug.message(classMethod + "got null attr map for realm " + realm);
}
return;
}
/*
* only doing the J2EEAgent and WebAgent Groups
* for now.
*/
SsoServerPolicyAgents sss = sunMib.getPolicyAgentsGroup();
TableSsoServerPolicyJ2EEGroupTable j2eetab = null;
TableSsoServerPolicyWebGroupTable wgtab = null;
SsoServerWSSAgents ssa = sunMib.getWssAgentsGroup();
TableSsoServerWSSAgentsSTSAgtGrpTable ststab = null;
TableSsoServerWSSAgentsWSPAgtGrpTable wsptab = null;
TableSsoServerWSSAgentsWSCAgtGrpTable wsctab = null;
TableSsoServerWSSAgentsDSCAgtGrpTable dsctab = null;
if (sss != null) {
try {
j2eetab = sss.accessSsoServerPolicyJ2EEGroupTable();
wgtab = sss.accessSsoServerPolicyWebGroupTable();
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting Agent Groups tables: ", ex);
// can't do anything without the tables
return;
}
}
if (ssa != null) {
try {
ststab = ssa.accessSsoServerWSSAgentsSTSAgtGrpTable();
wsptab = ssa.accessSsoServerWSSAgentsWSPAgtGrpTable();
wsctab = ssa.accessSsoServerWSSAgentsWSCAgtGrpTable();
dsctab = ssa.accessSsoServerWSSAgentsDSCAgtGrpTable();
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting WSS Agent Groups tables: ", ex);
// can't do anything without the tables
return;
}
}
StringBuilder sb = new StringBuilder(classMethod);
if (debug.messageEnabled()) {
sb.append("agents for realm ").append(realm).append(", # = ").append(agtAttrs.size()).append("\n");
}
// index for web agent groups
int wai = 1;
// index for j2ee agent groups
int j2eei = 1;
// index for STS agent groups
int stsi = 1;
// index for WSP agent groups
int wspi = 1;
// index for WSC agent groups
int wsci = 1;
// index for DSC agent groups
int dsci = 1;
Integer ri = getRealmIndexFromName(realm);
/*
* if the realm isn't in the table, there's not much point
* in doing the rest
*/
if (ri == null) {
debug.error(classMethod + "didn't find index for realm " + realm);
return;
}
for (Map.Entry<String, Map<String, String>> entry : agtAttrs.entrySet()) {
String agtname = entry.getKey();
Map<String, String> hm = entry.getValue();
String atype = hm.get(Constants.ATTR_NAME_AGENT_TYPE);
if (debug.messageEnabled()) {
sb.append(" agent group name = ").append(agtname).append(", type = ").append(atype).append("\n");
}
agtname = getEscapedString(agtname);
if (atype.equals("WebAgent")) {
if (wgtab == null) {
// no table to put it into
continue;
}
String lurl = hm.get("com.sun.identity.agents.config.login.url");
SsoServerPolicyWebGroupEntryImpl aei = new SsoServerPolicyWebGroupEntryImpl(sunMib);
aei.SsoServerRealmIndex = ri;
aei.PolicyWebGroupIndex = new Integer(wai++);
aei.PolicyWebGroupName = agtname;
aei.PolicyWebGroupServerURL = lurl;
ObjectName aname = aei.createSsoServerPolicyWebGroupEntryObjectName(server);
if (aname == null) {
debug.error(classMethod + "Error creating object for Policy Web Agent Group '" + agtname + "'");
continue;
}
try {
wgtab.addEntry(aei, aname);
if ((server != null) && (aei != null)) {
server.registerMBean(aei, aname);
}
} catch (JMException ex) {
debug.error(classMethod + agtname + ": " + ex.getMessage());
} catch (SnmpStatusException ex) {
debug.error(classMethod + agtname + ": " + ex.getMessage());
}
} else if (atype.equals("J2EEAgent")) {
if (j2eetab == null) {
// no table to put it into
continue;
}
SsoServerPolicyJ2EEGroupEntryImpl aei = new SsoServerPolicyJ2EEGroupEntryImpl(sunMib);
String lurl = hm.get("com.sun.identity.agents.config.login.url");
aei.PolicyJ2EEGroupServerURL = lurl;
aei.PolicyJ2EEGroupName = agtname;
aei.PolicyJ2EEGroupIndex = new Integer(j2eei++);
aei.SsoServerRealmIndex = ri;
ObjectName aname = aei.createSsoServerPolicyJ2EEGroupEntryObjectName(server);
if (aname == null) {
debug.error(classMethod + "Error creating object for Policy J2EE Agent Group '" + agtname + "'");
continue;
}
try {
j2eetab.addEntry(aei, aname);
if ((server != null) && (aei != null)) {
server.registerMBean(aei, aname);
}
} catch (JMException ex) {
debug.error(classMethod + agtname + ": " + ex.getMessage());
} catch (SnmpStatusException ex) {
debug.error(classMethod + agtname + ": " + ex.getMessage());
}
} else if (atype.equals("SharedAgent")) {
} else {
debug.error(classMethod + "agent group type = " + atype + ", agent group name = " + agtname + " not supported.");
}
}
if (debug.messageEnabled()) {
debug.message(sb.toString());
}
}
use of com.sun.management.snmp.SnmpStatusException 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.sun.management.snmp.SnmpStatusException in project OpenAM by OpenRock.
the class Agent method realmsConfig.
/**
* receive ordered list of realms
*/
public static int realmsConfig(List<String> realmList) {
String classMethod = "Agent.realmsConfig:";
/*
* no realm "service", so have to create the
* realm table here.
*/
Date startDate = new Date();
StringBuilder sb = new StringBuilder("receiving list of realms (size = ");
sb.append(realmList.size()).append("):\n");
SsoServerInstanceImpl sig = sunMib.getSvrInstanceGroup();
TableSsoServerRealmTable rtab = null;
if (sig != null) {
try {
rtab = sig.accessSsoServerRealmTable();
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting realm table: ", ex);
return -1;
}
}
int realmsAdded = 0;
for (int i = 0; i < realmList.size(); i++) {
String ss = realmList.get(i);
SsoServerRealmEntryImpl rei = new SsoServerRealmEntryImpl(sunMib);
rei.SsoServerRealmIndex = Integer.valueOf(i + 1);
String ss2 = ss;
ss2 = getEscapedString(ss2);
rei.SsoServerRealmName = ss2;
ObjectName oname = rei.createSsoServerRealmEntryObjectName(server);
if (oname == null) {
debug.error(classMethod + "Error creating object for realm '" + ss + "'");
continue;
}
String rlmToDN = DNMapper.orgNameToDN(ss);
sb.append(" realm #").append(i).append(" = ").append(ss).append(", DN = ").append(rlmToDN).append("\n");
/*
* each realm gets a realm-to-index, index-to-realm,
* realm-to-DN and DN-to-realm map entry
*/
try {
rtab.addEntry(rei, oname);
if ((server != null) && (rei != null)) {
server.registerMBean(rei, oname);
}
realm2Index.put(ss, rei.SsoServerRealmIndex);
index2Realm.put(rei.SsoServerRealmIndex, ss);
realm2DN.put(ss, rlmToDN);
DN2Realm.put(rlmToDN, ss);
} catch (JMException ex) {
debug.error(classMethod + ss, ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + ss, ex);
}
realmsAdded++;
}
/*
* could have used TableSsoServerRealmTable.getEntries(),
* but that's a little more complicated than just counting
* entries as they're successfully added here.
*/
if (realmsAdded == 0) {
debug.error(classMethod + "No realms processed successfully.");
return -2;
}
if (debug.messageEnabled()) {
debug.message(classMethod + sb.toString());
}
/*
* create the Entitlements MBeans for this realm as specified by Ii.
* the Network Monitors are not per-real. the set list is in
* MonitoringUtil.java (getNetworkMonitorNames()).
* the Policy Stats are realm-based.
*/
String[] nms = MonitoringUtil.getNetworkMonitorNames();
if ((nms != null) && (nms.length > 0)) {
SsoServerEntitlementSvc esi = sunMib.getEntitlementsGroup();
if (esi != null) {
try {
TableSsoServerEntitlementPolicyStatsTable ptab = esi.accessSsoServerEntitlementPolicyStatsTable();
for (int i = 0; i < realmList.size(); i++) {
String ss = realmList.get(i);
Integer Ii = Integer.valueOf(i + 1);
SsoServerEntitlementPolicyStatsEntryImpl ssi = new SsoServerEntitlementPolicyStatsEntryImpl(sunMib);
ssi.EntitlementPolicyCaches = 0;
ssi.EntitlementReferralCaches = 0;
ssi.EntitlementPolicyStatsIndex = Integer.valueOf(i + 1);
ssi.SsoServerRealmIndex = Ii;
ObjectName sname = ssi.createSsoServerEntitlementPolicyStatsEntryObjectName(server);
if (sname == null) {
debug.error(classMethod + "Error creating object for Entitlements " + "Policy Stats, realm = '" + ss + "'");
continue;
}
try {
ptab.addEntry(ssi, sname);
if ((server != null) && (ssi != null)) {
server.registerMBean(ssi, sname);
}
} catch (JMException ex) {
debug.error(classMethod + "on Entitlements Policy Stats '" + ss + "': ", ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + "on Entitlements Policy Stats '" + ss + "': ", ex);
}
}
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting Entitlements Policy Stats table: ", ex);
}
}
} else {
debug.error(classMethod + "Entitlement NetworkMonitor list empty.");
}
Date stopDate = new Date();
if (debug.messageEnabled()) {
String stDate = sdf.format(startDate);
String endDate = sdf.format(stopDate);
debug.message("Agent.realmsConfig:\n Start Time = " + stDate + "\n End Time = " + endDate);
}
return 0;
}
use of com.sun.management.snmp.SnmpStatusException in project OpenAM by OpenRock.
the class SsoServerLoggingSvcImpl method init.
private void init(SnmpMib myMib, MBeanServer server) {
if (debug == null) {
debug = Debug.getInstance("amMonitoring");
}
String classModule = "SsoServerLoggingServiceImpl.init:";
if (isBogus) {
int ind = 1;
// DB Handler
lg_dbh = new SsoServerLoggingHdlrEntryImpl(myMib);
lg_dbh.LoggingHdlrName = DB_HANDLER_NAME;
lg_dbh.LoggingHdlrIndex = new Integer(ind++);
final ObjectName dbhName = lg_dbh.createSsoServerLoggingHdlrEntryObjectName(server);
try {
SsoServerLoggingHdlrTable.addEntry(lg_dbh, dbhName);
if ((server != null) && (dbhName != null)) {
server.registerMBean(lg_dbh, dbhName);
}
handlerMap.put(DB_HANDLER_NAME, lg_dbh);
} catch (JMException ex) {
debug.error(classModule + DB_HANDLER_NAME, ex);
} catch (SnmpStatusException ex) {
debug.error(classModule + DB_HANDLER_NAME, ex);
}
// File Handler
lg_fh = new SsoServerLoggingHdlrEntryImpl(myMib);
lg_fh.LoggingHdlrName = FILE_HANDLER_NAME;
lg_fh.LoggingHdlrIndex = new Integer(ind++);
final ObjectName fhName = lg_fh.createSsoServerLoggingHdlrEntryObjectName(server);
try {
SsoServerLoggingHdlrTable.addEntry(lg_fh, fhName);
if ((server != null) && (fhName != null)) {
server.registerMBean(lg_fh, fhName);
}
handlerMap.put(FILE_HANDLER_NAME, lg_fh);
} catch (JMException ex) {
debug.error(classModule + FILE_HANDLER_NAME, ex);
} catch (SnmpStatusException ex) {
debug.error(classModule + FILE_HANDLER_NAME, ex);
}
// Secure File Handler
lg_sfh = new SsoServerLoggingHdlrEntryImpl(myMib);
lg_sfh.LoggingHdlrName = SECURE_FILE_HANDLER_NAME;
lg_sfh.LoggingHdlrIndex = new Integer(ind++);
final ObjectName sfhName = lg_sfh.createSsoServerLoggingHdlrEntryObjectName(server);
try {
SsoServerLoggingHdlrTable.addEntry(lg_sfh, sfhName);
if ((server != null) && (sfhName != null)) {
server.registerMBean(lg_sfh, sfhName);
}
handlerMap.put(SECURE_FILE_HANDLER_NAME, lg_sfh);
} catch (JMException ex) {
debug.error(classModule + SECURE_FILE_HANDLER_NAME, ex);
} catch (SnmpStatusException ex) {
debug.error(classModule + SECURE_FILE_HANDLER_NAME, ex);
}
// Remote Handler
lg_rh = new SsoServerLoggingHdlrEntryImpl(myMib);
lg_rh.LoggingHdlrName = REMOTE_HANDLER_NAME;
lg_rh.LoggingHdlrIndex = new Integer(ind++);
final ObjectName rhName = lg_rh.createSsoServerLoggingHdlrEntryObjectName(server);
try {
SsoServerLoggingHdlrTable.addEntry(lg_rh, rhName);
if ((server != null) && (rhName != null)) {
server.registerMBean(lg_rh, rhName);
}
handlerMap.put(REMOTE_HANDLER_NAME, lg_rh);
} catch (JMException ex) {
debug.error(classModule + REMOTE_HANDLER_NAME, ex);
} catch (SnmpStatusException ex) {
debug.error(classModule + REMOTE_HANDLER_NAME, ex);
}
}
}
use of com.sun.management.snmp.SnmpStatusException in project OpenAM by OpenRock.
the class Agent method realmConfigMonitoringAgent.
/**
* process configuration for a realm
*/
public static int realmConfigMonitoringAgent(SSOServerRealmInfo rlmInfo) {
String classMethod = "Agent.realmConfigMonitoringAgent:";
String realm = rlmInfo.realmName;
Map<String, String> authMods = rlmInfo.authModules;
Integer realmIndex = realm2Index.get(realm);
if (realmIndex == null) {
debug.error(classMethod + "could not find realm " + realm + " in realm2Index map");
return -1;
}
SsoServerAuthSvcImpl sig = sunMib.getAuthSvcGroup();
TableSsoServerAuthModulesTable atab = null;
if (sig != null) {
try {
atab = sig.accessSsoServerAuthModulesTable();
} catch (SnmpStatusException ex) {
debug.error(classMethod + "getting auth table: ", ex);
return -2;
}
}
StringBuilder sb = new StringBuilder();
if (debug.messageEnabled()) {
sb.append("receiving config info for realm = ").append(realm).append(":\n Authentication Modules:\n");
}
/*
* auth module table entries have realm index, and auth module index
*/
int i = 1;
for (Map.Entry<String, String> entry : authMods.entrySet()) {
String modInst = entry.getKey();
String modType = entry.getValue();
if (debug.messageEnabled()) {
sb.append(" instance = ").append(modInst).append(", value(type) = ").append(modType).append("\n");
}
SsoServerAuthModulesEntryImpl aei = new SsoServerAuthModulesEntryImpl(sunMib);
aei.SsoServerRealmIndex = realmIndex;
aei.AuthModuleIndex = new Integer(i++);
aei.AuthModuleName = modInst;
aei.AuthModuleType = getEscapedString(modType);
aei.AuthModuleSuccessCount = 0L;
aei.AuthModuleFailureCount = 0L;
ObjectName aname = aei.createSsoServerAuthModulesEntryObjectName(server);
if (aname == null) {
debug.error(classMethod + "Error creating object for auth module name '" + modInst + "', type '" + modType + "'");
continue;
}
try {
atab.addEntry(aei, aname);
if ((server != null) && (aei != null)) {
server.registerMBean(aei, aname);
}
/* is a Map of realm/authmodule to index needed? */
String rai = realm + "|" + modInst;
// aei is this module's SsoServerAuthModulesEntryImpl instance
realmAuthInst.put(rai, aei);
} catch (JMException ex) {
debug.error(classMethod + modInst, ex);
} catch (SnmpStatusException ex) {
debug.error(classMethod + modInst, ex);
}
}
// if no realm info added because mbean not created...
if (realmAuthInst.isEmpty()) {
return -3;
}
if (debug.messageEnabled()) {
debug.message(classMethod + sb.toString());
}
return 0;
}
Aggregations