use of java.net.MalformedURLException in project OpenAM by OpenRock.
the class IdRepoJAXRPCObjectImpl method isClientOnSameServer.
protected boolean isClientOnSameServer(String clientURL) {
// Check URL is not the local server
boolean success = true;
URL urlClient = null;
try {
urlClient = new URL(clientURL);
if (urlServer == null) {
urlServer = new URL(serverURL);
}
} catch (MalformedURLException e) {
if (idRepoDebug.warningEnabled()) {
idRepoDebug.warning("IdRepoJAXRPCObjectImpl." + "isClientOnSameServer() - clientURL is malformed " + clientURL);
}
success = false;
}
if (success) {
// check if it is the same server
int port = urlClient.getPort();
if (port == -1) {
// If it is Port 80, and is not explicilty in the URL
port = urlClient.getDefaultPort();
}
String clientPort = Integer.toString(port);
// Protocol is same - http, so no need to check that
boolean sameServer = ((urlServer.getHost().equalsIgnoreCase(urlClient.getHost())) && serverPort.equals(clientPort));
idRepoDebug.message("IdRepoJAXRPCObjectImpl:" + "checkIfClientOnSameServer() " + "Received registerNotification request from client: " + clientURL + " Server URL " + serverURL + " Port determined as: " + clientPort + " Check is: " + sameServer);
return sameServer;
} else {
return false;
}
}
use of java.net.MalformedURLException in project OpenAM by OpenRock.
the class SsoServerSiteMapEntryImpl method createSsoServerSiteMapEntryObjectName.
public ObjectName createSsoServerSiteMapEntryObjectName(MBeanServer server) {
String classModule = "SsoServerSiteMapEntryImpl." + "createSsoServerSiteMapEntryObjectName: ";
String prfx = "ssoServerSiteMapEntry.";
if (debug.messageEnabled()) {
debug.message(classModule + "\n SiteMapIndex = " + SiteMapIndex + "\n MapId = " + MapId + "\n SiteMapId = " + SiteMapId + "\n MapServerURL = " + MapServerURL + "\n MapSiteName = " + MapSiteName);
}
String host = null;
String path = null;
int port = 0;
try {
URL url = new URL(MapServerURL);
host = url.getHost();
port = url.getPort();
path = url.getPath();
} catch (MalformedURLException mue) {
debug.error(classModule + "invalid URL: " + MapServerURL + "; " + mue.getMessage());
return null;
}
String objname = myMibName + "/ssoServerSiteMapTable:" + prfx + "mapServerHost=" + host + "," + prfx + "mapServerPort=" + port + "," + prfx + "mapServerPath=" + path;
try {
if (server == null) {
return null;
} else {
// is the object name sufficiently unique?
return new ObjectName(objname);
}
} catch (Exception ex) {
debug.error(classModule + objname, ex);
return null;
}
}
use of java.net.MalformedURLException in project OpenAM by OpenRock.
the class SsoServerTopologyImpl method init.
private void init(SnmpMib myMib, MBeanServer server) {
if (debug == null) {
debug = Debug.getInstance("amMonitoring");
}
String classModule = "SsoServerTopologyImpl.init:";
/*
* server topology has the
* servers table (all servers known to this server)
* SsoServerServerTable
* sites table (sites and servers)
* SsoServerSiteMapTable
* site map table (site-to-server mapping)
* SsoServerSitesTable
*
* this init should get instances of
* SsoServerServerEntryImpl
* SsoServerSitesEntryImpl
* SsoServerSiteMapEntryImpl
* and add them to their corresponding tables.
*/
Map<String, String> ntbl = Agent.getNamingTable();
Map<String, String> sidtbl = Agent.getSiteIdTable();
for (Map.Entry<String, String> entry : sidtbl.entrySet()) {
String svrId = entry.getKey();
String svrURL = ntbl.get(svrId);
String siteId = sidtbl.get(svrId);
URL url = null;
String proto = null;
String host = null;
int port = 0;
try {
url = new URL(svrURL);
proto = url.getProtocol();
host = url.getHost();
port = url.getPort();
} catch (MalformedURLException mue) {
debug.error(classModule + "invalid URL: " + svrURL + "; " + mue.getMessage());
}
Integer iport = Integer.valueOf(1);
Integer iid = Integer.valueOf(0);
try {
iport = Integer.valueOf(port);
iid = Integer.valueOf(svrId);
} catch (NumberFormatException nfe) {
debug.error(classModule + "invalid port (" + port + ") or server id (" + svrId + "): " + nfe.getMessage(), nfe);
}
SsoServerServerEntryImpl ssrv = new SsoServerServerEntryImpl(myMib);
ssrv.ServerPort = iport;
ssrv.ServerHostName = host;
ssrv.ServerProtocol = proto;
ssrv.ServerId = iid;
/* need a way to know what the real status is */
ssrv.ServerStatus = Integer.valueOf(1);
final ObjectName svrName = ssrv.createSsoServerServerEntryObjectName(server);
try {
SsoServerServerTable.addEntry(ssrv, svrName);
if ((server != null) && (svrName != null)) {
server.registerMBean(ssrv, svrName);
}
} catch (Exception ex) {
debug.error(classModule + svrURL, ex);
}
/*
* fill the SsoServerSitesTable.
* entries have siteid, site name, and site state
* sidKeys has the serverIDs; the values are the site they
* belong to.
*
* unfortunately, SiteConfiguration.getSites(SSOToken) needs
* an SSOToken, which can be gotten after the server is more
* closer to being operational than when the Agent is started,
* so that part will have to be updated at a later time.
*
* where the key == value in sidKeys is the one that is the site
*/
if (debug.messageEnabled()) {
debug.message(classModule + "svrId = " + svrId + ", siteId = " + siteId);
}
try {
Integer.valueOf(siteId);
} catch (NumberFormatException nfe) {
debug.error(classModule + "invalid siteid (" + siteId + "): " + nfe.getMessage(), nfe);
}
}
}
use of java.net.MalformedURLException in project OpenAM by OpenRock.
the class SystemConfigurationUtil method getServiceAllURLs.
/**
* Returns all service urls.
* @return list of server names.
* @throws SystemConfigurationException if unable to get the server list.
*/
public static Collection getServiceAllURLs(String serviceName) throws SystemConfigurationException {
// TODO: Is this implementation still used?
if (!platformNamingInitialized) {
initPlatformNaming();
}
if (serviceName == null) {
throw new SystemConfigurationException("missingServiceName");
}
Collection allurls = null;
String name = "iplanet-am-naming-" + serviceName.toLowerCase() + "-url";
Set<String> values = null;
try {
values = (Set<String>) namingConfig.getConfiguration(null, null).get(name);
} catch (ConfigurationException cex) {
getDebug().error("SystemConfigurationUtil.getServiceURL:", cex);
}
if ((values) == null || values.isEmpty()) {
Object[] data = { serviceName };
throw new SystemConfigurationException("noServiceURL", data);
}
for (String url : values) {
if (url != null) {
try {
allurls.add(new URL(url));
} catch (MalformedURLException muex) {
Object[] data = { serviceName };
throw new SystemConfigurationException("noServiceURL", data);
}
} else {
Object[] data = { serviceName };
throw new SystemConfigurationException("noServiceURL", data);
}
}
return allurls;
}
use of java.net.MalformedURLException in project OpenAM by OpenRock.
the class WSPRedirectHandlerServlet method checkReturnToHost.
private boolean checkReturnToHost(String messageID, String returnToURL) {
boolean answer = false;
String requestHost = InteractionManager.getInstance().getRequestHost(messageID);
URL url = null;
if (requestHost != null) {
try {
url = new URL(returnToURL);
String returnToHost = url.getHost();
if (requestHost.equals(returnToHost)) {
answer = true;
}
} catch (MalformedURLException mfe) {
debug.error("WSPRedirecthandlerServlet.handleRequest():" + "malformed " + InteractionManager.RETURN_TO_URL + "=" + returnToURL);
}
}
String returnToHost = null;
if (url != null) {
returnToHost = url.getHost();
answer = requestHost.equalsIgnoreCase(returnToHost);
}
//requestHost does not include domain under jdk1.3
if ((answer == false) && (returnToHost.indexOf(requestHost + ".") == 0)) {
answer = true;
}
if (debug.messageEnabled()) {
debug.message("WSPRedirectHandlerServlet.checkReturnToHost():" + " returning: " + ":requestHost=" + requestHost + ":returnToHost=" + returnToHost + ":returnValue=" + answer);
}
return answer;
}
Aggregations