Search in sources :

Example 1 with FSNameRegistrationHandler

use of com.sun.identity.federation.services.registration.FSNameRegistrationHandler in project OpenAM by OpenRock.

the class FSSOAPReceiver method handleRegistrationRequest.

private FSNameRegistrationResponse handleRegistrationRequest(Element elt, SOAPMessage msg, ProviderDescriptorType hostedProviderDesc, BaseConfigType hostedConfig, String hostedRole, String realm, String hostedEntityId, String providerAlias, HttpServletRequest request, HttpServletResponse response) {
    try {
        FSNameRegistrationRequest regisRequest = new FSNameRegistrationRequest(elt);
        String remoteEntityId = regisRequest.getProviderId();
        boolean isIDP = false;
        if (hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
            isIDP = true;
        }
        ProviderDescriptorType remoteDesc = getRemoteProviderDescriptor(hostedRole, remoteEntityId, realm);
        if (remoteDesc == null) {
            return null;
        }
        X509Certificate cert = KeyUtil.getVerificationCert(remoteDesc, remoteEntityId, isIDP);
        if (!FSServiceUtils.isSigningOn() || verifyRequestSignature(elt, msg, cert)) {
            FSUtils.debug.message("Registration Signature successfully passed");
            IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
            if (metaManager.isTrustedProvider(realm, hostedEntityId, remoteEntityId)) {
                FSServiceManager instService = FSServiceManager.getInstance();
                if (instService != null) {
                    FSNameRegistrationHandler regisHandler = new FSNameRegistrationHandler();
                    regisHandler.setHostedDescriptor(hostedProviderDesc);
                    regisHandler.setHostedDescriptorConfig(hostedConfig);
                    regisHandler.setHostedEntityId(hostedEntityId);
                    regisHandler.setHostedProviderRole(hostedRole);
                    regisHandler.setMetaAlias(providerAlias);
                    regisHandler.setRealm(realm);
                    regisHandler.setRemoteDescriptor(remoteDesc);
                    regisHandler.setRemoteEntityId(remoteEntityId);
                    FSNameRegistrationResponse regisResponse = regisHandler.processSOAPRegistrationRequest(request, response, regisRequest);
                    return regisResponse;
                } else {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("FSServiceManager instance is null. " + "Cannot process registration request");
                    }
                    return null;
                }
            }
            FSUtils.debug.error("Remote provider not in trusted list");
            return null;
        } else {
            FSUtils.debug.message("Registration Signature failed verification");
            return null;
        }
    } catch (Exception se) {
        FSUtils.debug.error("FSNameRegistrationHandler.doPost.doGet:Exception occured ", se);
        return null;
    }
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) ProviderDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType) FSNameRegistrationHandler(com.sun.identity.federation.services.registration.FSNameRegistrationHandler) FSNameRegistrationResponse(com.sun.identity.federation.message.FSNameRegistrationResponse) FSNameRegistrationRequest(com.sun.identity.federation.message.FSNameRegistrationRequest) X509Certificate(java.security.cert.X509Certificate) SOAPException(javax.xml.soap.SOAPException) SystemConfigurationException(com.sun.identity.common.SystemConfigurationException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) FSException(com.sun.identity.federation.common.FSException)

Example 2 with FSNameRegistrationHandler

use of com.sun.identity.federation.services.registration.FSNameRegistrationHandler in project OpenAM by OpenRock.

the class FSServiceManager method getNameRegistrationHandler.

/*
     * Returns name registration handler. This method is invoked by the
     * <code>SP</code> at the end of account federation if name registration is
     * turned on.
     * The <code>remoteEntityId</code> passed is that of the <code>IdP</code>
     * with whom registration will be done.
     * @param realm the realm in which the provider resides
     * @param remoteEntityId remote Provider Entity ID. 
     * @param remoteProviderRole remote Provider Role.
     * @return <code>FSNameRegistrationHandler</code> the name registration 
     *  handler
     */
public FSNameRegistrationHandler getNameRegistrationHandler(String realm, String remoteEntityId, String remoteProviderRole) {
    FSNameRegistrationHandler handlerRegistration = new FSNameRegistrationHandler();
    if (handlerRegistration != null) {
        try {
            IDFFMetaManager metaManager = FSUtils.getIDFFMetaManager();
            if (metaManager == null) {
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("FSNameRegistrationHandler::" + "getSPNameIdentifier failed to get meta " + "Manager instance");
                }
                return null;
            }
            ProviderDescriptorType remoteDesc = null;
            if (remoteProviderRole == null) {
                return null;
            } else if (remoteProviderRole.equalsIgnoreCase(IFSConstants.IDP)) {
                remoteDesc = metaManager.getIDPDescriptor(realm, remoteEntityId);
            } else if (remoteProviderRole.equalsIgnoreCase(IFSConstants.SP)) {
                remoteDesc = metaManager.getSPDescriptor(realm, remoteEntityId);
            }
            if (remoteDesc != null) {
                handlerRegistration.setRemoteDescriptor(remoteDesc);
                handlerRegistration.setRemoteEntityId(remoteEntityId);
                handlerRegistration.setRealm(realm);
                return handlerRegistration;
            } else {
                return null;
            }
        } catch (IDFFMetaException e) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSNameRegistrationHandler::Failed " + "to get remote descriptor:", e);
            }
            return null;
        }
    }
    return handlerRegistration;
}
Also used : IDFFMetaManager(com.sun.identity.federation.meta.IDFFMetaManager) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ProviderDescriptorType(com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType) FSNameRegistrationHandler(com.sun.identity.federation.services.registration.FSNameRegistrationHandler)

Aggregations

IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)2 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)2 FSNameRegistrationHandler (com.sun.identity.federation.services.registration.FSNameRegistrationHandler)2 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)2 SystemConfigurationException (com.sun.identity.common.SystemConfigurationException)1 FSException (com.sun.identity.federation.common.FSException)1 FSNameRegistrationRequest (com.sun.identity.federation.message.FSNameRegistrationRequest)1 FSNameRegistrationResponse (com.sun.identity.federation.message.FSNameRegistrationResponse)1 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)1 X509Certificate (java.security.cert.X509Certificate)1 SOAPException (javax.xml.soap.SOAPException)1