use of com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement in project OpenAM by OpenRock.
the class SPSSOFederate method getACSUrl.
/**
* Returns an Ordered Set containing the AssertionConsumerServiceURL
* and AssertionConsumerServiceIndex.
*/
static OrderedSet getACSUrl(SPSSODescriptorElement spsso, String binding) {
String responseBinding = binding;
if ((binding != null) && (binding.length() > 0) && (binding.indexOf(SAML2Constants.BINDING_PREFIX) == -1)) {
responseBinding = new StringBuffer().append(SAML2Constants.BINDING_PREFIX).append(binding).toString();
}
List acsList = spsso.getAssertionConsumerService();
String acsURL = null;
if (acsList != null && !acsList.isEmpty()) {
Iterator ac = acsList.iterator();
while (ac.hasNext()) {
AssertionConsumerServiceElement ace = (AssertionConsumerServiceElement) ac.next();
if ((ace != null && ace.isIsDefault()) && (responseBinding == null || responseBinding.length() == 0)) {
acsURL = ace.getLocation();
responseBinding = ace.getBinding();
break;
} else if ((ace != null) && (ace.getBinding().equals(responseBinding))) {
acsURL = ace.getLocation();
break;
}
}
}
OrderedSet ol = new OrderedSet();
ol.add(acsURL);
ol.add(responseBinding);
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("SPSSOFederate: AssertionConsumerService :" + " URL :" + acsURL);
SAML2Utils.debug.message("SPSSOFederate: AssertionConsumerService :" + " Binding Passed in Query: " + binding);
SAML2Utils.debug.message("SPSSOFederate: AssertionConsumerService :" + " Binding : " + responseBinding);
}
return ol;
}
use of com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement in project OpenAM by OpenRock.
the class TaskModelImpl method setAcsUrl.
/**
* Saves the Salesforce login url as the Assertion Consumer Service Location
* @param realm Realm
* @param entityId Entity Name
* @param acsUrl assertion consumer service location
* @throws AMConsoleException if value cannot be saved.
*/
public void setAcsUrl(String realm, String entityId, String acsUrl) throws AMConsoleException {
SPSSODescriptorElement spssoDescriptor = null;
try {
SAML2MetaManager samlManager = new SAML2MetaManager();
EntityDescriptorElement entityDescriptor = samlManager.getEntityDescriptor(realm, entityId);
spssoDescriptor = samlManager.getSPSSODescriptor(realm, entityId);
if (spssoDescriptor != null) {
List asconsServiceList = spssoDescriptor.getAssertionConsumerService();
for (Iterator i = asconsServiceList.listIterator(); i.hasNext(); ) {
AssertionConsumerServiceElement acsElem = (AssertionConsumerServiceElement) i.next();
if (acsElem.getBinding().contains("HTTP-POST")) {
acsElem.setLocation(acsUrl);
}
}
samlManager.setEntityDescriptor(realm, entityDescriptor);
}
} catch (SAML2MetaException e) {
debug.warning("SAMLv2ModelImpl.setSPStdAttributeValues:", e);
}
}
use of com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement in project OpenAM by OpenRock.
the class IDPSSOUtil method getACSurlFromMetaByIndex.
/**
* Returns the assertion consumer service <code>URL</code> from
* meta data by binding
*
* @param spEntityID the entity id of the service provider
* @param realm the realm name of the identity provider
* @param acsIndex the <code>ACS</code> index
* @param returnedBinding the binding used to send back
* <code>Response</code>
* @return the assertion consumer service <code>URL</code>
* @throws SAML2Exception if the operation is not successful
*/
public static String getACSurlFromMetaByIndex(String spEntityID, String realm, int acsIndex, StringBuffer returnedBinding) throws SAML2Exception {
String classMethod = "IDPSSOUtil.getACSurlFromMetaByIndex: ";
SPSSODescriptorElement spSSODescriptorElement = getSPSSODescriptor(realm, spEntityID, classMethod);
List acsList = spSSODescriptorElement.getAssertionConsumerService();
int index;
String acsURL = null;
String binding = null;
String defaultAcsURL = null;
String defaultBinding = null;
String firstAcsURL = null;
String firstBinding = null;
AssertionConsumerServiceElement acs = null;
for (int i = 0; i < acsList.size(); i++) {
acs = (AssertionConsumerServiceElement) acsList.get(i);
index = acs.getIndex();
binding = acs.getBinding();
if (index == acsIndex) {
acsURL = acs.getLocation();
binding = acs.getBinding();
break;
}
if (acs.isIsDefault()) {
defaultAcsURL = acs.getLocation();
defaultBinding = acs.getBinding();
}
if (i == 0) {
firstAcsURL = acs.getLocation();
firstBinding = acs.getBinding();
}
}
if (acsURL == null || acsURL.length() == 0) {
acsURL = defaultAcsURL;
if (acsURL == null || acsURL.length() == 0) {
acsURL = firstAcsURL;
if (acsURL == null || acsURL.length() == 0) {
acsURL = null;
SAML2Utils.debug.error(classMethod + "Unable to get valid Assertion " + "Consumer Service URL");
return null;
}
returnedBinding.append(firstBinding);
} else {
returnedBinding.append(defaultBinding);
}
} else {
returnedBinding.append(binding);
}
return acsURL;
}
use of com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement in project OpenAM by OpenRock.
the class IDPSSOUtil method getBindingForAcsUrl.
/**
* Returns the assertion consumer service url binding from
* the metadata.
*
* @param spEntityID the entity id of the service provider
* @param realm the realm name of the identity provider
* @return the assertion consumer service url binding
* @throws SAML2Exception if the operation is not successful
*/
public static String getBindingForAcsUrl(String spEntityID, String realm, String acsURL) throws SAML2Exception {
String classMethod = "IDPSSOUtil.getBindingForAcsUrl: ";
SPSSODescriptorElement spSSODescriptorElement = getSPSSODescriptor(realm, spEntityID, classMethod);
List acsList = spSSODescriptorElement.getAssertionConsumerService();
AssertionConsumerServiceElement acs = null;
String binding = null;
for (int i = 0; i < acsList.size(); i++) {
acs = (AssertionConsumerServiceElement) acsList.get(i);
String location = acs.getLocation();
if (location != null && location.equals(acsURL)) {
return acs.getBinding();
}
}
return null;
}
use of com.sun.identity.saml2.jaxb.metadata.AssertionConsumerServiceElement in project OpenAM by OpenRock.
the class IDPSSOUtil method isACSurlValidInMetadataSP.
/**
* Validates if the Assertion Consumer Service URL acsURL exists in the
* metadata of the Service Provider spEntityID
*
* @param acsURL the assertion consumer service <code>URL</code>
* @param spEntityID the entity id of the service provider
* @param realm the realm name of the identity provider
* @return true if the assertion consumer service URL was found
* false otherwise
*/
private static boolean isACSurlValidInMetadataSP(String acsURL, String spEntityID, String realm) throws SAML2Exception {
boolean isValidACSurl = false;
String classMethod = "IDPSSOUtil.isACSurlValidInMetadataSP: ";
SPSSODescriptorElement spSSODescriptorElement = getSPSSODescriptor(realm, spEntityID, classMethod);
List acsList = spSSODescriptorElement.getAssertionConsumerService();
AssertionConsumerServiceElement acs = null;
for (int i = 0; i < acsList.size(); i++) {
acs = (AssertionConsumerServiceElement) acsList.get(i);
String acsInMeta = acs.getLocation();
if (acsInMeta.equalsIgnoreCase(acsURL)) {
isValidACSurl = true;
SAML2Utils.debug.message(classMethod + " acsURL=" + acsURL + "Found in the metadata");
break;
}
}
return isValidACSurl;
}
Aggregations