use of com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType in project OpenAM by OpenRock.
the class FSTerminationInitiationServlet method doGetPost.
/**
* Invoked when the user clicks on the termination link in the application.
* @param request <code>HttpServletRequest</code> object that contains the
* request the client has made of the servlet.
* @param response <code>HttpServletResponse</code> object that contains
* the response the servlet sends to the client.
* @exception ServletException,IOException if the request could not be
* handled
*/
private void doGetPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Alias processing
String providerAlias = request.getParameter(IFSConstants.META_ALIAS);
if (providerAlias == null || providerAlias.length() < 1) {
FSUtils.debug.error("Unable to retrieve alias, Hosted Provider. " + "Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("aliasNotFound"));
return;
}
if (metaManager == null) {
FSUtils.debug.error("Cannot retrieve hosted descriptor. " + "Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
ProviderDescriptorType hostedProviderDesc = null;
BaseConfigType hostedConfig = null;
String hostedRole = null;
String hostedEntityId = null;
String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
try {
hostedRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
hostedProviderDesc = metaManager.getSPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
} else if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
hostedProviderDesc = metaManager.getIDPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
}
if (hostedProviderDesc == null) {
throw new IDFFMetaException((String) null);
}
} catch (IDFFMetaException eam) {
FSUtils.debug.error("Unable to find Hosted Provider. not process request", eam);
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
boolean isIDP = false;
if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
isIDP = true;
}
if (FSUtils.needSetLBCookieAndRedirect(request, response, isIDP)) {
return;
}
this.request = request;
setTerminationURL(hostedConfig, providerAlias);
doTerminationInitiation(request, response, hostedProviderDesc, hostedConfig, realm, hostedEntityId, hostedRole, providerAlias);
return;
}
use of com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType in project OpenAM by OpenRock.
the class FSRegistrationRequestServlet method doGetPost.
/**
* Handles registration request.
* in the application
* @param request <code>HttpServletRequest</code> object that contains the
* request the client has made of the servlet.
* @param response <code>HttpServletResponse</code> object that contains
* the response the servlet sends to the client.
* @exception IOException if the request could not be handled
*/
private void doGetPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Alias processing
String providerAlias = FSServiceUtils.getMetaAlias(request);
if (providerAlias == null || providerAlias.length() < 1) {
FSUtils.debug.error("Unable to retrieve alias, Hosted " + "Provider. Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("aliasNotFound"));
return;
}
if (metaManager == null) {
FSUtils.debug.error("Cannot retrieve hosted descriptor. " + "Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
ProviderDescriptorType hostedProviderDesc = null;
BaseConfigType hostedConfig = null;
String hostedEntityId = null;
String hostedProviderRole = null;
try {
hostedProviderRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
if (hostedProviderRole != null && hostedProviderRole.equalsIgnoreCase(IFSConstants.IDP)) {
hostedProviderDesc = metaManager.getIDPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
} else if (hostedProviderRole != null && hostedProviderRole.equalsIgnoreCase(IFSConstants.SP)) {
hostedProviderDesc = metaManager.getSPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
}
if (hostedProviderDesc == null) {
throw new IDFFMetaException((String) null);
}
} catch (IDFFMetaException eam) {
FSUtils.debug.error("Unable to find Hosted Provider. not process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
this.request = request;
setRegistrationURL(hostedConfig, providerAlias);
FSNameRegistrationRequest regisRequest = new FSNameRegistrationRequest();
try {
regisRequest = FSNameRegistrationRequest.parseURLEncodedRequest(request);
} catch (FSMsgException e) {
FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
return;
} catch (SAMLException e) {
FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
return;
}
if (regisRequest == null) {
FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_REQUEST_IMPROPER, IFSConstants.REGISTRATION_FAILED);
} else {
doRequestProcessing(request, response, hostedProviderDesc, hostedConfig, hostedProviderRole, realm, hostedEntityId, providerAlias, regisRequest);
}
}
use of com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType in project OpenAM by OpenRock.
the class FSRegistrationRequestServlet method doRequestProcessing.
/**
* Called when a registration request is received from
* a remote provider. Initiates registration request processing.
* @param request <code>HTTPServletRequest</code> object received via a
* HTTP Redirect
* @param response <code>HTTPServletResponse</code> object to send the
* response back to user agent
* @param hostedProviderDesc the provider for whom request is received
* @param hostedConfig hosted provider's extended meta
* @param hostedProviderRole hosted provider's role
* @param realm the realm under which the provider resides
* @param hostedEntityId hosted provider's entity ID
* @param providerAlias hosted provider's meta alias
* @param regisRequest the federation registration request
*/
private void doRequestProcessing(HttpServletRequest request, HttpServletResponse response, ProviderDescriptorType hostedProviderDesc, BaseConfigType hostedConfig, String hostedProviderRole, String realm, String hostedEntityId, String providerAlias, FSNameRegistrationRequest regisRequest) {
FSUtils.debug.message("Entered FSRegistrationRequestServlet::doRequestProcessing");
String remoteEntityId = regisRequest.getProviderId();
String retURL = null;
ProviderDescriptorType remoteDesc = null;
boolean isIDP = false;
try {
if (hostedProviderRole.equalsIgnoreCase(IFSConstants.SP)) {
remoteDesc = metaManager.getIDPDescriptor(realm, remoteEntityId);
isIDP = true;
} else {
remoteDesc = metaManager.getSPDescriptor(realm, remoteEntityId);
}
retURL = remoteDesc.getRegisterNameIdentifierServiceReturnURL();
} catch (IDFFMetaException e) {
FSUtils.debug.error("FSRegistrationRequestServlet.doRequest " + "Processing: Can not retrieve remote provider data." + remoteEntityId);
String[] data = { remoteEntityId, realm };
LogUtil.error(Level.INFO, LogUtil.INVALID_PROVIDER, data);
FSServiceUtils.returnToSource(response, retURL, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_FAILED, IFSConstants.METADATA_ERROR);
return;
}
boolean bVerify = true;
if (FSServiceUtils.isSigningOn()) {
try {
if (remoteDesc != null) {
FSUtils.debug.message("Calling verifyRegistrationSignature");
bVerify = verifyRegistrationSignature(request, remoteDesc, remoteEntityId, isIDP);
} else {
FSUtils.debug.error("Cannot retrieve provider descriptor.");
String[] data = { remoteEntityId, realm };
LogUtil.error(Level.INFO, LogUtil.INVALID_PROVIDER, data);
FSServiceUtils.returnToSource(response, retURL, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_FAILED, IFSConstants.METADATA_ERROR);
return;
}
} catch (FSException e) {
FSUtils.debug.error("FSRegistrationRequestServlet::processRegistrationRequest " + "Signature on registration request is invalid" + "Cannot proceed federation registration");
String[] data = { FSUtils.bundle.getString(IFSConstants.REGISTRATION_INVALID_SIGNATURE) };
LogUtil.error(Level.INFO, LogUtil.INVALID_SIGNATURE, data);
FSServiceUtils.returnToSource(response, retURL, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_FAILED, IFSConstants.METADATA_ERROR);
return;
} catch (SAMLException e) {
FSUtils.debug.error("FSRegistrationRequestServlet::processRegistrationRequest" + "Signature on registration request is invalid" + "Cannot proceed federation registration");
String[] data = { FSUtils.bundle.getString(IFSConstants.REGISTRATION_INVALID_SIGNATURE) };
LogUtil.error(Level.INFO, LogUtil.INVALID_SIGNATURE, data);
FSServiceUtils.returnToSource(response, retURL, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_FAILED, IFSConstants.METADATA_ERROR);
return;
}
}
if (bVerify) {
// Check if trusted provider
if (metaManager.isTrustedProvider(realm, hostedEntityId, remoteEntityId)) {
FSNameRegistrationHandler regisHandler = new FSNameRegistrationHandler();
if (regisHandler != null) {
regisHandler.setHostedDescriptor(hostedProviderDesc);
regisHandler.setHostedDescriptorConfig(hostedConfig);
regisHandler.setRemoteDescriptor(remoteDesc);
regisHandler.setRemoteEntityId(remoteEntityId);
regisHandler.setHostedEntityId(hostedEntityId);
regisHandler.setHostedProviderRole(hostedProviderRole);
regisHandler.setMetaAlias(providerAlias);
regisHandler.setRealm(realm);
regisHandler.processRegistrationRequest(request, response, regisRequest);
return;
} else {
FSUtils.debug.error("Unable to get registration " + "handler. User account Not valid");
}
} else {
FSUtils.debug.error("Remote provider not in trusted list");
}
} else {
FSUtils.debug.error("FSRegistrationRequestServlet::doRequestProcesing " + "Signature on registration request is invalid" + "Cannot proceed name registration");
String[] data = { FSUtils.bundle.getString(IFSConstants.REGISTRATION_INVALID_SIGNATURE) };
LogUtil.error(Level.INFO, LogUtil.INVALID_SIGNATURE, data);
}
FSServiceUtils.returnToSource(response, retURL, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_FAILED, IFSConstants.METADATA_ERROR);
return;
}
use of com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType in project OpenAM by OpenRock.
the class FSRegistrationInitiationServlet method doGetPost.
/**
* Invoked when the user clicks on the registration link in the application.
* @param request <code>HttpServletRequest</code> object that contains the
* request the client has made of the servlet.
* @param response <code>HttpServletResponse</code> object that contains
* the response the servlet sends to the client.
* @exception ServletException, IOException if the request could not be
* handled
*/
private void doGetPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Alias processing
String providerAlias = request.getParameter(IFSConstants.META_ALIAS);
if (providerAlias == null || providerAlias.length() < 1) {
FSUtils.debug.error("Unable to retrieve alias, Hosted Provider. " + "Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("aliasNotFound"));
return;
}
if (metaManager == null) {
FSUtils.debug.error("Cannot retrieve hosted descriptor. " + "Cannot process request");
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
ProviderDescriptorType hostedProviderDesc = null;
BaseConfigType hostedConfig = null;
String hostedRole = null;
String hostedEntityId = null;
String realm = IDFFMetaUtils.getRealmByMetaAlias(providerAlias);
try {
hostedRole = metaManager.getProviderRoleByMetaAlias(providerAlias);
hostedEntityId = metaManager.getEntityIDByMetaAlias(providerAlias);
if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
hostedProviderDesc = metaManager.getSPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getSPDescriptorConfig(realm, hostedEntityId);
} else if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
hostedProviderDesc = metaManager.getIDPDescriptor(realm, hostedEntityId);
hostedConfig = metaManager.getIDPDescriptorConfig(realm, hostedEntityId);
}
if (hostedProviderDesc == null) {
throw new IDFFMetaException((String) null);
}
} catch (IDFFMetaException eam) {
FSUtils.debug.error("Unable to find Hosted Provider. not process request", eam);
response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString(IFSConstants.FAILED_HOSTED_DESCRIPTOR));
return;
}
boolean isIDP = false;
if (hostedRole != null && hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
isIDP = true;
}
if (FSUtils.needSetLBCookieAndRedirect(request, response, isIDP)) {
return;
}
this.request = request;
setRegistrationURL(hostedConfig, providerAlias);
doRegistrationInitiation(request, response, hostedProviderDesc, hostedConfig, hostedEntityId, hostedRole, providerAlias);
}
use of com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType in project OpenAM by OpenRock.
the class FSSingleLogoutHandler method returnAfterCompletion.
/**
* Invoked to either send back control to remote provider if logout message
* was received from one or
* to show the local logout status page to the user.
*/
protected void returnAfterCompletion() {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("Entered FSSingleLogoutHandler::returnAC: " + "PROTOCOL=" + this.singleLogoutProtocol + ", relayState=" + this.relayState);
}
try {
String returnProviderId = "";
String relayState = "";
String logoutStatusString = "";
String inResponseTo = "";
FSReturnSessionManager mngInst = FSReturnSessionManager.getInstance(metaAlias);
HashMap providerMap = new HashMap();
if (mngInst != null) {
providerMap = mngInst.getUserProviderInfo(userID);
}
if (providerMap != null) {
returnProviderId = (String) providerMap.get(IFSConstants.PROVIDER);
relayState = (String) providerMap.get(IFSConstants.LOGOUT_RELAY_STATE);
logoutStatusString = (String) providerMap.get(IFSConstants.LOGOUT_STATUS);
if (logoutStatusString == null || logoutStatusString.length() == 0) {
logoutStatusString = IFSConstants.SAML_SUCCESS;
}
inResponseTo = (String) providerMap.get(IFSConstants.RESPONSE_TO);
mngInst.removeUserProviderInfo(userID);
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("Deleted " + returnProviderId + " from return list");
}
ProviderDescriptorType descriptor = null;
if (hostedRole.equalsIgnoreCase(IFSConstants.IDP)) {
descriptor = metaManager.getSPDescriptor(realm, returnProviderId);
} else {
descriptor = metaManager.getIDPDescriptor(realm, returnProviderId);
}
String retURL = descriptor.getSingleLogoutServiceReturnURL();
if (retURL != null) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("Getting provider " + returnProviderId + " IDP Return URL = " + retURL);
}
FSLogoutResponse responseLogout = new FSLogoutResponse();
responseLogout.setResponseTo(inResponseTo);
responseLogout.setRelayState(relayState);
responseLogout.setProviderId(hostedEntityId);
responseLogout.setStatus(logoutStatusString);
responseLogout.setID(IFSConstants.LOGOUTID);
responseLogout.setMinorVersion(getMinorVersion(descriptor));
responseLogout.setResponseID(FSUtils.generateID());
// Call SP Adapter postSingleLogoutSuccess for SP/HTTP
callPostSingleLogoutSuccess(responseLogout, IFSConstants.LOGOUT_IDP_REDIRECT_PROFILE);
// call multi-federation protocol processing
if (MultiProtocolUtils.isMultipleProtocolSession(request, SingleLogoutManager.IDFF) && hostedRole.equalsIgnoreCase(IFSConstants.IDP) && !MultiProtocolUtils.isMultiProtocolRelayState(relayState)) {
int retStatus = handleMultiProtocolLogout(false, responseLogout.toXMLString(true, true), returnProviderId);
if (retStatus == SingleLogoutManager.LOGOUT_REDIRECTED_STATUS) {
return;
} else {
if ((retStatus == SingleLogoutManager.LOGOUT_FAILED_STATUS) || (retStatus == SingleLogoutManager.LOGOUT_PARTIAL_STATUS)) {
responseLogout.setStatus(IFSConstants.SAML_RESPONDER);
}
}
}
String urlEncodedResponse = responseLogout.toURLEncodedQueryString();
// Sign the request querystring
if (FSServiceUtils.isSigningOn()) {
String certAlias = IDFFMetaUtils.getFirstAttributeValueFromConfig(hostedConfig, IFSConstants.SIGNING_CERT_ALIAS);
if (certAlias == null || certAlias.length() == 0) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSBrowserArtifactConsumerHandler:: " + "signSAMLRequest:" + "couldn't obtain this site's cert alias.");
}
throw new SAMLResponderException(FSUtils.bundle.getString(IFSConstants.NO_CERT_ALIAS));
}
urlEncodedResponse = FSSignatureUtil.signAndReturnQueryString(urlEncodedResponse, certAlias);
}
StringBuffer redirectURL = new StringBuffer();
redirectURL.append(retURL);
if (retURL.indexOf(IFSConstants.QUESTION_MARK) == -1) {
redirectURL.append(IFSConstants.QUESTION_MARK);
} else {
redirectURL.append(IFSConstants.AMPERSAND);
}
redirectURL.append(urlEncodedResponse);
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("Response to be sent : " + redirectURL.toString());
}
String[] data = { userID };
LogUtil.access(Level.INFO, LogUtil.LOGOUT_SUCCESS, data);
response.sendRedirect(redirectURL.toString());
return;
}
} else {
FSUtils.debug.message("no source provider. return to local status page");
// Multiple protocol single logout handler
if ((this.singleLogoutProtocol != null) && this.singleLogoutProtocol.equals(IFSConstants.LOGOUT_IDP_SOAP_PROFILE) && (this.relayState != null) && MultiProtocolUtils.isMultiProtocolRelayState(this.relayState)) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSSingleLogoutHandler::returnAC:" + " this is multiProto for IDP initiated SOAP");
}
return;
}
// call multi-federation protocol processing
if (MultiProtocolUtils.isMultipleProtocolSession(request, SingleLogoutManager.IDFF) && hostedRole.equalsIgnoreCase(IFSConstants.IDP) && !MultiProtocolUtils.isMultiProtocolRelayState(relayState)) {
boolean isSOAPInitiated = false;
if ((singleLogoutProtocol.equals(IFSConstants.LOGOUT_IDP_SOAP_PROFILE)) || (singleLogoutProtocol.equals(IFSConstants.LOGOUT_SP_SOAP_PROFILE))) {
isSOAPInitiated = true;
}
int retStatus = handleMultiProtocolLogout(isSOAPInitiated, null, remoteEntityId);
if (retStatus == SingleLogoutManager.LOGOUT_REDIRECTED_STATUS) {
return;
} else {
if ((retStatus == SingleLogoutManager.LOGOUT_FAILED_STATUS) || (retStatus == SingleLogoutManager.LOGOUT_PARTIAL_STATUS)) {
logoutStatus = false;
}
}
}
if (logoutStatus) {
FSServiceUtils.returnLocallyAfterOperation(response, LOGOUT_DONE_URL, true, IFSConstants.LOGOUT_SUCCESS, IFSConstants.LOGOUT_FAILURE);
}
return;
}
} catch (IDFFMetaException e) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("Unable to get LRURL. " + "No location to redirect. processing completed");
}
String[] data = { FSUtils.bundle.getString(IFSConstants.LOGOUT_REDIRECT_FAILED) };
LogUtil.error(Level.INFO, LogUtil.LOGOUT_REDIRECT_FAILED, data, ssoToken);
} catch (Exception ex) {
String[] data = { FSUtils.bundle.getString(IFSConstants.LOGOUT_REDIRECT_FAILED) };
LogUtil.error(Level.INFO, LogUtil.LOGOUT_REDIRECT_FAILED, data, ssoToken);
}
}
Aggregations