use of com.sun.identity.saml2.protocol.NameIDMappingRequest in project OpenAM by OpenRock.
the class NameIDMapping method getNameID.
private static NameID getNameID(NameIDMappingRequest nimRequest, String realm, String idpEntityID) {
NameID nameID = nimRequest.getNameID();
if (nameID == null) {
EncryptedID encryptedID = nimRequest.getEncryptedID();
try {
final IDPSSOConfigElement idpSsoConfig = metaManager.getIDPSSOConfig(realm, idpEntityID);
nameID = encryptedID.decrypt(KeyUtil.getDecryptionKeys(idpSsoConfig));
} catch (SAML2Exception ex) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("NameIDMapping.getNameID:", ex);
}
return null;
}
}
if (!SAML2Utils.isPersistentNameID(nameID)) {
return null;
}
return nameID;
}
use of com.sun.identity.saml2.protocol.NameIDMappingRequest in project OpenAM by OpenRock.
the class NameIDMappingServiceSOAP method doPost.
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
// handle DOS attack
SAMLUtils.checkHTTPContentLength(req);
// Get IDP entity ID
String idpMetaAlias = SAML2MetaUtils.getMetaAliasByUri(req.getRequestURI());
String idpEntityID = SAML2Utils.getSAML2MetaManager().getEntityByMetaAlias(idpMetaAlias);
String realm = SAML2MetaUtils.getRealmByMetaAlias(idpMetaAlias);
if (!SAML2Utils.isIDPProfileBindingSupported(realm, idpEntityID, SAML2Constants.NAMEID_MAPPING_SERVICE, SAML2Constants.SOAP)) {
throw new SAML2Exception(SAML2Utils.bundle.getString("unsuppoprtedBinding"));
}
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("NameIDMappingServiceSOAP.doPost : " + "uri = " + req.getRequestURI() + ", idpMetaAlias = " + idpMetaAlias + ", idpEntityID = " + idpEntityID);
}
SOAPMessage msg = SOAPCommunicator.getInstance().getSOAPMessage(req);
Element reqElem = SOAPCommunicator.getInstance().getSamlpElement(msg, SAML2Constants.NAME_ID_MAPPING_REQUEST);
NameIDMappingRequest nimRequest = ProtocolFactory.getInstance().createNameIDMappingRequest(reqElem);
NameIDMappingResponse nimResponse = NameIDMapping.processNameIDMappingRequest(nimRequest, realm, idpEntityID);
SOAPMessage reply = SOAPCommunicator.getInstance().createSOAPMessage(nimResponse.toXMLString(true, true), false);
if (reply != null) {
if (reply.saveRequired()) {
reply.saveChanges();
}
resp.setStatus(HttpServletResponse.SC_OK);
SAML2Utils.putHeaders(reply.getMimeHeaders(), resp);
OutputStream os = resp.getOutputStream();
reply.writeTo(os);
os.flush();
}
} catch (SAML2Exception ex) {
SAML2Utils.debug.error("NameIDMappingServiceSOAP", ex);
SAMLUtils.sendError(req, resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "nameIDMappingFailed", ex.getMessage());
return;
} catch (SOAPException soap) {
SAML2Utils.debug.error("NameIDMappingServiceSOAP", soap);
SAMLUtils.sendError(req, resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "nameIDMappingFailed", soap.getMessage());
return;
}
}
Aggregations