use of com.sun.identity.cot.CircleOfTrustManager 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.CircleOfTrustManager 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.CircleOfTrustManager in project OpenAM by OpenRock.
the class AddProviderToCOT method addToCOT.
public static void addToCOT(String realm, String cot, String entityId) throws COTException {
CircleOfTrustManager cotManager = new CircleOfTrustManager();
if (!cotManager.getAllCirclesOfTrust(realm).contains(cot)) {
CircleOfTrustDescriptor desc = new CircleOfTrustDescriptor(cot, realm, COTConstants.ACTIVE, "", null, null, null, null, Collections.EMPTY_SET);
cotManager.createCircleOfTrust(realm, desc);
}
cotManager.addCircleOfTrustMember(realm, cot, COTConstants.SAML2, entityId);
}
use of com.sun.identity.cot.CircleOfTrustManager in project OpenAM by OpenRock.
the class FSAuthDomainsModelImpl method getCircleOfTrustDescriptors.
public Set getCircleOfTrustDescriptors() {
Set descSet = new HashSet();
String realm = COTConstants.ROOT_REALM;
try {
CircleOfTrustManager manager = getCircleOfTrustManager();
Set realmSet = getRealmNames("/", "*");
for (Iterator i = realmSet.iterator(); i.hasNext(); ) {
realm = (String) i.next();
Set cotSet = manager.getAllCirclesOfTrust(realm);
for (Iterator j = cotSet.iterator(); j.hasNext(); ) {
String cotName = (String) j.next();
CircleOfTrustDescriptor descriptor = manager.getCircleOfTrust(realm, cotName);
descSet.add(descriptor);
}
}
} catch (COTException e) {
String[] paramsEx = { realm, getErrorString(e) };
logEvent("FEDERATION_EXCEPTION_GET_AUTH_DOMAINS", paramsEx);
debug.warning("FSAuthDomainsModelImpl.getAuthenticationDomains", e);
} catch (AMConsoleException e) {
debug.warning("FSAuthDomainsModelImpl.getAuthenticationDomains", e);
}
return descSet;
}
use of com.sun.identity.cot.CircleOfTrustManager in project OpenAM by OpenRock.
the class FSAuthDomainsModelImpl method createAuthenticationDomain.
/**
* Creates authentication domain.
*
* @param attrValues Map of attribute name to set of attribute values.
* @throws AMConsoleException if authentication domain created.
*/
public void createAuthenticationDomain(Map attrValues, Set providers) throws AMConsoleException {
String realm = (String) AMAdminUtils.getValue((Set) attrValues.get(SINGLE_CHOICE_REALM));
String status = (String) AMAdminUtils.getValue((Set) attrValues.get(SINGLE_CHOICE_STATUS));
String name = (String) AMAdminUtils.getValue((Set) attrValues.get(TF_NAME));
if (name.trim().length() == 0) {
throw new AMConsoleException("authdomain.authentication.domain.name.missing.message");
}
String[] param = { name };
logEvent("ATTEMPT_CREATE_AUTH_DOMAIN", param);
try {
CircleOfTrustDescriptor descriptor = new CircleOfTrustDescriptor(name, realm, status);
descriptor.setTrustedProviders(providers);
descriptor.setCircleOfTrustDescription((String) AMAdminUtils.getValue((Set) attrValues.get(TF_DESCRIPTION)));
descriptor.setIDFFReaderServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(TF_IDFF_READER_SERVICE_URL)));
descriptor.setIDFFWriterServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(TF_IDFF_WRITER_SERVICE_URL)));
descriptor.setSAML2ReaderServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(TF_SAML2_READER_SERVICE_URL)));
descriptor.setSAML2WriterServiceURL((String) AMAdminUtils.getValue((Set) attrValues.get(TF_SAML2_WRITER_SERVICE_URL)));
CircleOfTrustManager manager = getCircleOfTrustManager();
manager.createCircleOfTrust(realm, descriptor);
logEvent("SUCCEED_CREATE_AUTH_DOMAIN", param);
} catch (COTException e) {
String strError = getErrorString(e);
String[] paramsEx = { name, strError };
logEvent("FEDERATION_EXCEPTION_CREATE_AUTH_DOMAIN", paramsEx);
throw new AMConsoleException(strError);
}
}
Aggregations