use of com.sun.identity.cot.CircleOfTrustDescriptor 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.CircleOfTrustDescriptor in project OpenAM by OpenRock.
the class FSAuthDomainsModelImpl method getRealm.
/**
* Returns realm that have name matching
*
* @param name Base realm name for this search. null indicates root
* suffix.
* @return realm that have name matching
* @throws AMConsoleException if search fails.
*/
public String getRealm(String name) throws AMConsoleException {
String realm = null;
Set s = getCircleOfTrustDescriptors();
for (Iterator iter = s.iterator(); iter.hasNext() && realm == null; ) {
CircleOfTrustDescriptor desc = (CircleOfTrustDescriptor) iter.next();
String cotName = desc.getCircleOfTrustName();
if (cotName.equals(name)) {
realm = desc.getCircleOfTrustRealm();
}
}
return realm;
}
use of com.sun.identity.cot.CircleOfTrustDescriptor 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.CircleOfTrustDescriptor 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);
}
}
use of com.sun.identity.cot.CircleOfTrustDescriptor in project OpenAM by OpenRock.
the class SAML2IDPProxyFRImpl method getPreferredIDP.
/**
* Returns a list of preferred IDP providerIDs.
* @param authnRequest original authnrequest
* @param hostProviderID ProxyIDP providerID.
* @param realm Realm
* @param request HttpServletRequest
* @param response HttpServletResponse
* @return a list of providerID's of the authenticating providers to be
* proxied or <code>null</code> to disable the proxying and continue
* for the localauthenticating provider.
* @exception SAML2Exception if error occurs.
*/
public List getPreferredIDP(AuthnRequest authnRequest, String hostProviderID, String realm, HttpServletRequest request, HttpServletResponse response) throws SAML2Exception {
// Entering the class and method
String methodName = "getPreferredIDP";
String classMethod = className + methodName + ":";
debugMessage(methodName, "Entering.");
Boolean isIdpFinderForAllSPsEnabled = isIDPFinderForAllSPs(realm, hostProviderID);
// Start the logic to obtain the list of preferred IdPs
try {
// Inititate the metadata manager
SAML2MetaManager sm = new SAML2MetaManager();
if (sm == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("errorMetaManager"));
}
// Obtain the SP configuration
try {
spSSODescriptor = IDPSSOUtil.metaManager.getSPSSODescriptor(realm, authnRequest.getIssuer().getValue().toString());
} catch (SAML2MetaException sme) {
SAML2Utils.debug.error(classMethod, sme);
spSSODescriptor = null;
}
// Get the relay state from the request, if exists
relayState = request.getParameter(SAML2Constants.RELAY_STATE);
binding = SAML2Constants.HTTP_REDIRECT;
if (request.getMethod().equals("POST")) {
binding = SAML2Constants.HTTP_POST;
}
// Read the local metadata of the SP that made the request
SPSSOConfigElement spEntityCfg = sm.getSPSSOConfig(realm, authnRequest.getIssuer().getValue());
Map spConfigAttrsMap = null;
if (spEntityCfg != null) {
spConfigAttrsMap = SAML2MetaUtils.getAttributes(spEntityCfg);
}
// Check if the local configuration of the remote SP wants to use
// the Introduction Cookie
Boolean isIntroductionForProxyingEnabled = false;
String useIntroductionForProxying = SPSSOFederate.getParameter(spConfigAttrsMap, SAML2Constants.USE_INTRODUCTION_FOR_IDP_PROXY);
if (useIntroductionForProxying != null)
isIntroductionForProxyingEnabled = useIntroductionForProxying.equalsIgnoreCase("true");
// Check if the local configuration of the remote SP wants to use
// the IDP Finder
Boolean isIdPFinderEnabled = false;
String idpFinderEnabled = SPSSOFederate.getParameter(spConfigAttrsMap, IDP_FINDER_ENABLED_IN_SP);
if (idpFinderEnabled != null)
isIdPFinderEnabled = idpFinderEnabled.equalsIgnoreCase("true");
String idpFinderJSP = getIDPFinderJSP(realm, hostProviderID);
// providerIDs will contain the list of IdPs to return from this method
List providerIDs = new ArrayList();
// extended metadata
if (!isIntroductionForProxyingEnabled && !isIdPFinderEnabled && !isIdpFinderForAllSPsEnabled) {
debugMessage(methodName, " idpFinder wil use the static list of the SP");
List<String> proxyIDPs = null;
if (spConfigAttrsMap != null && !spConfigAttrsMap.isEmpty()) {
proxyIDPs = (List<String>) spConfigAttrsMap.get(SAML2Constants.IDP_PROXY_LIST);
}
debugMessage(methodName, " List from the configuration: " + proxyIDPs);
if (proxyIDPs == null || proxyIDPs.isEmpty()) {
SAML2Utils.debug.error("SAML2IDPProxyImpl.getPrefferedIDP:" + "Preferred IDPs are null.");
return null;
}
// give the user the chance to select one interactively
if (proxyIDPs.size() > 1) {
String idpListSt = selectIDPBasedOnLOA(proxyIDPs, realm, authnRequest);
// Construct the IDPFinder URL to redirect to
String idpFinder = getRedirect(request, idpFinderJSP);
// Generate the requestID
String requestID = SAML2Utils.generateID();
// Store the important stuff and the session parameters so the
// idpFinderImplemenatation can read them and process them
storeSessionParamsAndCache(request, idpListSt, authnRequest, hostProviderID, realm, requestID);
debugMessage(methodName, ": Redirect url = " + idpFinder);
response.sendRedirect(idpFinder);
// return something different than null
providerIDs.add(requestID);
debugMessage(methodName, " Redirected successfully");
return providerIDs;
}
providerIDs.add(proxyIDPs.iterator().next());
return providerIDs;
}
// and it does not want to use the introduction cookie
if (!isIntroductionForProxyingEnabled && (isIdPFinderEnabled || isIdpFinderForAllSPsEnabled)) {
debugMessage(methodName, "SP wants to use IdP Finder");
String idpListSt = idpList(authnRequest, realm);
if (!idpListSt.trim().isEmpty()) {
// Construct the IDPFinder URL to redirect to
String idpFinder = getRedirect(request, idpFinderJSP);
// Generate the requestID
String requestID = SAML2Utils.generateID();
// Store the important stuff and the session parameters so the
// idpFinderImplemenatation can read them and process them
storeSessionParamsAndCache(request, idpListSt, authnRequest, hostProviderID, realm, requestID);
debugMessage(methodName, ": Redirect url = " + idpFinder);
response.sendRedirect(idpFinder);
// return something different than null
providerIDs.add(requestID);
debugMessage(methodName, " Redirected successfully");
return providerIDs;
} else {
return null;
}
} else {
// IDP Proxy with introduction cookie
List cotList = (List) spConfigAttrsMap.get("cotlist");
String cotListStr = (String) cotList.iterator().next();
CircleOfTrustManager cotManager = new CircleOfTrustManager();
CircleOfTrustDescriptor cotDesc = cotManager.getCircleOfTrust(realm, cotListStr);
String readerURL = cotDesc.getSAML2ReaderServiceURL();
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message(classMethod + "SAMLv2 idp" + "discovery reader URL = " + readerURL);
}
if (readerURL != null && (!readerURL.equals(""))) {
String rID = SAML2Utils.generateID();
String redirectURL = SAML2Utils.getRedirectURL(readerURL, rID, request);
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.error(classMethod + "Redirect url = " + redirectURL);
}
if (redirectURL != null) {
response.sendRedirect(redirectURL);
Map aMap = new HashMap();
SPCache.reqParamHash.put(rID, aMap);
providerIDs.add(rID);
return providerIDs;
}
}
}
return null;
} catch (SAML2MetaException ex) {
SAML2Utils.debug.error(classMethod + "meta Exception in retrieving the preferred IDP", ex);
return null;
} catch (COTException sme) {
SAML2Utils.debug.error(classMethod + "Error retreiving COT ", sme);
return null;
} catch (Exception e) {
SAML2Utils.debug.error(classMethod + "Exception in retrieving the preferred IDP", e);
return null;
}
}
Aggregations