use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class GetCircleOfTrusts method execute.
/**
* Returns Circle of trust of a given realm or extended metadata.
*
* @param locale Locale of the request.
* @param params Map of creation parameters.
*/
public String execute(Locale locale, Map params) throws WorkflowException {
String realm = getString(params, ParameterKeys.P_REALM);
if (realm == null) {
String extendedMetaData = getString(params, ParameterKeys.P_EXTENDED_DATA);
if (extendedMetaData != null) {
realm = getRealmFromExtData(getContent(extendedMetaData, locale));
}
}
if (realm == null) {
throw new WorkflowException("invalid-metaalias-slash", null);
}
try {
CircleOfTrustManager mgr = new CircleOfTrustManager();
Set cots = mgr.getAllCirclesOfTrust(realm);
StringBuffer buff = new StringBuffer();
if ((cots != null) && !cots.isEmpty()) {
boolean first = true;
for (Iterator i = cots.iterator(); i.hasNext(); ) {
String c = (String) i.next();
if (first) {
first = false;
} else {
buff.append("|");
}
try {
buff.append(StringUtils.encodeURIComponent(c, "UTF-8"));
} catch (UnsupportedEncodingException e) {
buff.append(c);
}
}
}
return buff.toString();
} catch (COTException e) {
throw new WorkflowException("invalid-extended-data-cot", null);
}
}
use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class GetHostedIDPs method execute.
public String execute(Locale locale, Map params) throws WorkflowException {
String realm = getString(params, ParameterKeys.P_REALM);
String cot = getString(params, ParameterKeys.P_COT);
try {
CircleOfTrustManager cotMgr = new CircleOfTrustManager();
Set entities = cotMgr.listCircleOfTrustMember(realm, cot, COTConstants.SAML2);
SAML2MetaManager mgr = new SAML2MetaManager();
StringBuffer buff = new StringBuffer();
boolean first = true;
for (Iterator i = entities.iterator(); i.hasNext(); ) {
String entityId = (String) i.next();
EntityConfigElement elm = mgr.getEntityConfig(realm, entityId);
// elm could be null due to OPENAM-269
if (elm != null && elm.isHosted()) {
EntityDescriptorElement desc = mgr.getEntityDescriptor(realm, entityId);
if (SAML2MetaUtils.getIDPSSODescriptor(desc) != null) {
if (first) {
first = false;
} else {
buff.append("|");
}
buff.append(entityId);
}
}
}
return buff.toString();
} catch (COTException e) {
throw new WorkflowException(e.getMessage(), null);
} catch (SAML2MetaException e) {
throw new WorkflowException(e.getMessage(), null);
}
}
use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class LibertyManager method getListOfCOTs.
/**
* Returns the List of COTs for the given Provider under a realm.
*
* @param realm The realm under which the entity resides.
* @param providerId The ID of the provider whose <code>COTList</code>
* is to be found
* @param providerRole The Role of the provider whose <code>COTList</code>
* is to be found
* @return The set containing the authentication domains for the given
* provider.
*/
public static Set getListOfCOTs(String realm, String providerId, String providerRole) {
Set returnSet = new HashSet();
BaseConfigType hostConfig = IDFFMetaUtils.getExtendedConfig(realm, providerId, providerRole, metaManager);
if (hostConfig != null) {
List cotSet = IDFFMetaUtils.getAttributeValueFromConfig(hostConfig, IFSConstants.COT_LIST);
if (cotSet != null && !cotSet.isEmpty()) {
Iterator iter = cotSet.iterator();
while (iter.hasNext()) {
String cotID = (String) iter.next();
try {
CircleOfTrustManager cotManager = new CircleOfTrustManager();
CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, cotID);
String tldURL = cotDesc.getIDFFWriterServiceURL();
String cotStatus = cotDesc.getCircleOfTrustStatus();
if (tldURL != null && tldURL.length() > 0 && cotStatus.equalsIgnoreCase(IFSConstants.ACTIVE)) {
returnSet.add((String) cotID);
}
} catch (COTException fsExp) {
debug.error("LibertyManager: getListOfCots " + "COTException caught ", fsExp);
}
}
}
if (returnSet != null && returnSet.size() > 0) {
if (debug.messageEnabled()) {
debug.message("LibertyManager: getListOfCots returning " + " cot set with " + returnSet);
}
} else {
if (debug.messageEnabled()) {
debug.message("LibertyManager::getListOfCots returning" + " null. Looks like COT is not set");
}
}
}
return returnSet;
}
use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class ConfigFedMonitoring method getCOTs.
private Set getCOTs(String realm, CircleOfTrustManager cotmgr) {
String classMethod = "ConfigFedMonitoring.getCOTs: ";
Set cotSet = null;
try {
cotSet = cotmgr.getAllCirclesOfTrust(realm);
} catch (COTException e) {
debug.error(classMethod + "COTMgr error: " + e.getMessage());
}
return cotSet;
}
use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class FSIDPFinderService method getCommonDomainIDP.
/**
* Gets a preferred IDP from the common domain cookie.
* @param request HttpServletRequest
* @param response HttpServletResponse
* @param realm The realm under which the entity resides.
* @param entityID Hosted entity ID.
* @param requestID Original Authentication Request ID.
* @exception FSRedirectException for the redirection.
* IOException for any redirection failure.
*/
private String getCommonDomainIDP(HttpServletRequest request, HttpServletResponse response, String realm, String entityID, String requestID) throws FSRedirectException, IOException {
String idpID = FSUtils.findPreferredIDP(realm, request);
if (idpID != null) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSIDPFinderService.getCommonDomainIDP:" + "Preferred IDP found from the common domain." + idpID);
}
if (requestCotSetMap.containsKey(requestID)) {
requestCotSetMap.remove(requestID);
}
return idpID;
}
Set tmpCotSet = (Set) requestCotSetMap.get(requestID);
if (tmpCotSet == null) {
try {
IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
List cotList = null;
if (metaManager != null) {
BaseConfigType spConfig = metaManager.getSPDescriptorConfig(realm, entityID);
cotList = IDFFMetaUtils.getAttributeValueFromConfig(spConfig, IFSConstants.COT_LIST);
}
if (cotList != null) {
tmpCotSet = new HashSet();
tmpCotSet.addAll(cotList);
}
} catch (IDFFMetaException ie) {
FSUtils.debug.error("FSIDPFinderService.getCommonDomainIDP:cannot get meta:", ie);
return null;
}
}
if (tmpCotSet == null || tmpCotSet.isEmpty()) {
FSUtils.debug.message("FSIDPFinderService.getCommonDomainIDP::No more Cots.");
if (requestCotSetMap.containsKey(requestID)) {
requestCotSetMap.remove(requestID);
}
return null;
}
Iterator iter = tmpCotSet.iterator();
while (iter.hasNext()) {
String cotName = (String) iter.next();
iter.remove();
requestCotSetMap.put(requestID, tmpCotSet);
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSIDPFinderService.getCommonDomainIDP: Trying Cot: " + cotName);
}
String readerServiceURL = null;
try {
CircleOfTrustManager cotManager = new CircleOfTrustManager();
CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, cotName);
if (cotDesc != null && (cotDesc.getCircleOfTrustStatus()).equalsIgnoreCase(IFSConstants.ACTIVE)) {
readerServiceURL = cotDesc.getIDFFReaderServiceURL();
}
} catch (COTException fe) {
FSUtils.debug.error("FSIDPFinderService.getCommonDomainIDP:" + "Unable to retrieve reader service url.", fe);
}
if (readerServiceURL != null) {
String baseURL = FSServiceUtils.getBaseURL(request);
StringBuffer returnURL = new StringBuffer(300);
returnURL.append(baseURL).append(IFSConstants.IDP_FINDER_URL).append("?").append("RequestID").append("=").append(URLEncDec.encode(requestID)).append("&").append("Realm=").append(URLEncDec.encode(realm)).append("&").append("ProviderID=").append(URLEncDec.encode(entityID));
StringBuffer redirectURL = new StringBuffer(300);
redirectURL.append(readerServiceURL).append("?").append(IFSConstants.LRURL).append("=").append(URLEncDec.encode(returnURL.toString()));
String url = redirectURL.toString();
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSIDPFinderService.getCommonDomainIDP:Redirection URL:" + url);
}
response.setHeader("Location", url);
response.sendRedirect(url);
throw new FSRedirectException(FSUtils.bundle.getString("Redirection_Happened"));
}
}
return null;
}
Aggregations