use of com.sun.identity.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class ExportSAML2MetaData method exportExtendedMeta.
public static String exportExtendedMeta(String realm, String entityID) throws WorkflowException {
try {
String result = null;
SAML2MetaManager metaManager = new SAML2MetaManager();
EntityConfigElement config = metaManager.getEntityConfig(realm, entityID);
if (config != null) {
OutputStream os = new ByteArrayOutputStream();
SAML2MetaUtils.convertJAXBToOutputStream(config, os);
result = os.toString();
}
return result;
} catch (JAXBException e) {
throw new WorkflowException(e.getMessage());
} catch (SAML2MetaException e) {
throw new WorkflowException(e.getMessage());
}
}
use of com.sun.identity.saml2.meta.SAML2MetaManager 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.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class MetaDataParser method getSSOUrl.
/**
*get SSO URL
*
*/
private String getSSOUrl() {
try {
SAML2MetaManager manager = new SAML2MetaManager();
IDPSSODescriptorElement idp = manager.getIDPSSODescriptor("/", getIDPEntityID());
List ssoServiceList = idp.getSingleSignOnService();
if ((ssoServiceList != null) && (!ssoServiceList.isEmpty())) {
Iterator i = ssoServiceList.iterator();
while (i.hasNext()) {
SingleSignOnServiceElement sso = (SingleSignOnServiceElement) i.next();
if ((sso != null) && (sso.getBinding() != null)) {
String ssoURL = sso.getLocation();
int loc = ssoURL.indexOf("/metaAlias/");
if (loc == -1) {
continue;
} else {
return ssoURL;
}
}
}
}
return null;
} catch (SAML2MetaException ex) {
Logger.getLogger(MetaDataParser.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
use of com.sun.identity.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class MetaDataParser method getSPEntityID.
/**
*get SP Entity ID
*
*/
public String getSPEntityID() {
String spEntityID = null;
try {
SAML2MetaManager manager = new SAML2MetaManager();
List spEntities = manager.getAllHostedServiceProviderEntities("/");
if ((spEntities != null) && !spEntities.isEmpty()) {
spEntityID = (String) spEntities.get(0);
}
return spEntityID;
} catch (SAML2MetaException ex) {
Logger.getLogger(MetaDataParser.class.getName()).log(Level.SEVERE, null, ex);
}
return spEntityID;
}
use of com.sun.identity.saml2.meta.SAML2MetaManager in project OpenAM by OpenRock.
the class MetaDataParser method getIDPEntityID.
/**
*get IDP Entity ID
*
*/
public String getIDPEntityID() {
String idpEntityID = null;
try {
SAML2MetaManager manager = new SAML2MetaManager();
List idpEntities = manager.getAllRemoteIdentityProviderEntities("/");
if ((idpEntities != null) && !idpEntities.isEmpty()) {
idpEntityID = (String) idpEntities.get(0);
}
return idpEntityID;
} catch (SAML2MetaException ex) {
Logger.getLogger(MetaDataParser.class.getName()).log(Level.SEVERE, null, ex);
}
return idpEntityID;
}
Aggregations