Search in sources :

Example 1 with FSAccountFedInfo

use of com.sun.identity.federation.accountmgmt.FSAccountFedInfo in project OpenAM by OpenRock.

the class FSNameMappingHandler method getNameIdentifier.

/**
     * Returns <code>NameIdentifier</code> of a provider.
     * @param userID user id.
     * @param remoteEntityID the provider id whose
     *  <code>NameIdentifier</code> is to be returned.
     * @param local <code>true</code> if <code>remoteProviderID</code> is
     *  a local provider; <code>false</code> otherwise.
     * @return <code>NameIdentifier</code> of an user corresponding to
     *  <code>remoteProviderID</code>.
     * @exception FSAccountMgmtException, SAMLException if an error occurred.
     */
public NameIdentifier getNameIdentifier(String userID, String remoteEntityID, boolean local) throws FSAccountMgmtException, SAMLException {
    FSAccountFedInfo accountInfo = accountMgr.readAccountFedInfo(userID, remoteEntityID);
    NameIdentifier nameIdentifier = null;
    if (local) {
        nameIdentifier = accountInfo.getLocalNameIdentifier();
        if (nameIdentifier == null) {
            NameIdentifier remoteNI = accountInfo.getRemoteNameIdentifier();
            if (remoteNI != null) {
                nameIdentifier = new NameIdentifier(remoteNI.getName(), hostedEntityID, remoteNI.getFormat());
            }
        }
    } else {
        nameIdentifier = accountInfo.getRemoteNameIdentifier();
        if (nameIdentifier == null) {
            NameIdentifier localNI = accountInfo.getLocalNameIdentifier();
            if (localNI != null) {
                nameIdentifier = new NameIdentifier(localNI.getName(), remoteEntityID, localNI.getFormat());
            }
        }
    }
    if (nameIdentifier != null && (nameIdentifier.getFormat().length() == 0 || nameIdentifier.getFormat() == null)) {
        nameIdentifier.setFormat(IFSConstants.NI_FEDERATED_FORMAT_URI);
    }
    return nameIdentifier;
}
Also used : FSAccountFedInfo(com.sun.identity.federation.accountmgmt.FSAccountFedInfo) NameIdentifier(com.sun.identity.saml.assertion.NameIdentifier)

Example 2 with FSAccountFedInfo

use of com.sun.identity.federation.accountmgmt.FSAccountFedInfo in project OpenAM by OpenRock.

the class FSNameRegistrationHandler method setUserDN.

/**
     * Determines the user based on the registration request received from 
     * a remote provider.
     * @param regisRequest the name registration request
     * @return <code>true</code> a user is found; <code>false</code> otherwise.
     */
public boolean setUserDN(FSNameRegistrationRequest regisRequest) {
    try {
        /**
             * UserDN needs to be figured from registration request
             * 1. If OldNameIdentifier does not exist then its from SP to IdP
             *    (first time)
             * 2. If OldNameIdentifier exist then we could be SP, IdP 
             * Need to find out whether to replace with SPNI or IDPNI based on 
             * acctFedInfo that is retrieved based on OldNameIdentifier or
             * IdpNameIdentifier
             * If isIDP true then remote is IdP so replace remoteIdentifier
             * with IDPNameIdentifier.
             * If isIDP false then  remote is SP so replace remoteIdentifier 
             * with SPNameIdentifier
             */
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("remoteEntityId : " + remoteEntityId);
        }
        Map env = new HashMap();
        env.put(IFSConstants.FS_USER_PROVIDER_ENV_REGISTRATION_KEY, regisRequest);
        OldProvidedNameIdentifier oldNameIdentifier = regisRequest.getOldProvidedNameIdentifier();
        IDPProvidedNameIdentifier idpNameIdentifier = regisRequest.getIDPProvidedNameIdentifier();
        SPProvidedNameIdentifier spNameIdentifier = regisRequest.getSPProvidedNameIdentifier();
        if (oldNameIdentifier == null) {
            FSUtils.debug.message("oldProvidedNameIdentifier is null :");
            String opaqueHandle = idpNameIdentifier.getName();
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("processRegistrationRequest IdPName : " + opaqueHandle);
            }
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("Realm : " + realm);
            }
            String searchDomain = hostedEntityId;
            String nameQualifier = idpNameIdentifier.getNameQualifier();
            if (nameQualifier != null && (nameQualifier.length() != 0) && !nameQualifier.equals(remoteEntityId)) {
                searchDomain = nameQualifier;
            }
            FSAccountFedInfoKey acctkey = new FSAccountFedInfoKey(searchDomain, opaqueHandle);
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("Search based on:" + hostedEntityId + opaqueHandle);
            }
            this.userID = managerInst.getUserID(acctkey, realm, env);
            if (this.userID == null) {
                FSUtils.debug.message("UserID is null");
                return false;
            }
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("user id is " + userID);
            }
            try {
                acctInfo = managerInst.readAccountFedInfo(userID, remoteEntityId, opaqueHandle);
            } catch (FSAccountMgmtException e) {
                FSUtils.debug.message("Failed to read account information");
                return false;
            }
            newAcctInfo = new FSAccountFedInfo(remoteEntityId, idpNameIdentifier, spNameIdentifier, false);
            newAcctInfo.setAffiliation(acctInfo.getAffiliation());
            newAcctKey = new FSAccountFedInfoKey(searchDomain, idpNameIdentifier.getName());
            return true;
        } else {
            FSUtils.debug.message("oldProvidedNameIdentifier not null");
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("Realm : " + realm);
            }
            String opaqueHandle = "";
            String nameQualifier = null;
            boolean isSPEmpty = false;
            String searchDomain = hostedEntityId;
            if (spNameIdentifier != null && !(spNameIdentifier.equals(oldNameIdentifier))) {
                opaqueHandle = spNameIdentifier.getName();
                nameQualifier = spNameIdentifier.getNameQualifier();
            } else {
                isSPEmpty = true;
                opaqueHandle = idpNameIdentifier.getName();
                nameQualifier = idpNameIdentifier.getNameQualifier();
            }
            if (nameQualifier != null && (nameQualifier.length() != 0) && !nameQualifier.equals(hostedEntityId)) {
                searchDomain = nameQualifier;
            }
            FSAccountFedInfoKey acctkey = new FSAccountFedInfoKey(searchDomain, opaqueHandle);
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("Search based on :" + searchDomain + " " + opaqueHandle);
            }
            this.userID = managerInst.getUserID(acctkey, realm, env);
            if (this.userID == null) {
                FSUtils.debug.message("UserID is null in step 3");
                opaqueHandle = idpNameIdentifier.getName();
                nameQualifier = idpNameIdentifier.getNameQualifier();
                if (nameQualifier != null && (nameQualifier.length() != 0) && !nameQualifier.equals(hostedEntityId)) {
                    searchDomain = nameQualifier;
                }
                acctkey = new FSAccountFedInfoKey(searchDomain, opaqueHandle);
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("Search based on :" + searchDomain + " " + opaqueHandle);
                }
                this.userID = managerInst.getUserID(acctkey, realm, env);
                if (this.userID == null) {
                    opaqueHandle = idpNameIdentifier.getName();
                    searchDomain = hostedEntityId;
                    acctkey = new FSAccountFedInfoKey(searchDomain, opaqueHandle);
                    this.userID = managerInst.getUserID(acctkey, realm, env);
                    if (this.userID == null) {
                        if (FSUtils.debug.messageEnabled()) {
                            FSUtils.debug.message("UserID is null in " + "step 4");
                        }
                        opaqueHandle = oldNameIdentifier.getName();
                        searchDomain = oldNameIdentifier.getNameQualifier();
                        if ((searchDomain != null) && (searchDomain.length() != 0)) {
                            acctkey = new FSAccountFedInfoKey(searchDomain, opaqueHandle);
                            if (FSUtils.debug.messageEnabled()) {
                                FSUtils.debug.message("Search based on :" + searchDomain + " " + opaqueHandle);
                            }
                            this.userID = managerInst.getUserID(acctkey, realm, env);
                        }
                    }
                    if (this.userID == null) {
                        return false;
                    } else {
                        if (FSUtils.debug.messageEnabled()) {
                            FSUtils.debug.message("Found user : " + userID);
                        }
                        acctInfo = managerInst.readAccountFedInfo(userID, searchDomain, opaqueHandle);
                        if (acctInfo == null || !acctInfo.isFedStatusActive()) {
                            acctInfo = managerInst.readAccountFedInfo(userID, remoteEntityId, opaqueHandle);
                        }
                        if (acctInfo.isRoleIDP()) {
                            if (isSPEmpty) {
                                // set spNI to null since is empty
                                newAcctInfo = new FSAccountFedInfo(remoteEntityId, null, idpNameIdentifier, acctInfo.isRoleIDP());
                                newAcctInfo.setAffiliation(acctInfo.getAffiliation());
                                newAcctKey = new FSAccountFedInfoKey(searchDomain, idpNameIdentifier.getName());
                            } else {
                                newAcctInfo = new FSAccountFedInfo(remoteEntityId, spNameIdentifier, idpNameIdentifier, acctInfo.isRoleIDP());
                                newAcctInfo.setAffiliation(acctInfo.getAffiliation());
                                newAcctKey = new FSAccountFedInfoKey(searchDomain, spNameIdentifier.getName());
                            }
                        } else {
                            newAcctInfo = new FSAccountFedInfo(remoteEntityId, idpNameIdentifier, spNameIdentifier, acctInfo.isRoleIDP());
                            newAcctInfo.setAffiliation(acctInfo.getAffiliation());
                            newAcctKey = new FSAccountFedInfoKey(hostedEntityId, idpNameIdentifier.getName());
                        }
                    }
                } else {
                    acctInfo = managerInst.readAccountFedInfo(userID, searchDomain, opaqueHandle);
                    if (acctInfo == null || !acctInfo.isFedStatusActive()) {
                        acctInfo = managerInst.readAccountFedInfo(userID, remoteEntityId, opaqueHandle);
                    }
                    newAcctInfo = new FSAccountFedInfo(remoteEntityId, idpNameIdentifier, spNameIdentifier, false);
                    newAcctInfo.setAffiliation(acctInfo.getAffiliation());
                    newAcctKey = new FSAccountFedInfoKey(searchDomain, idpNameIdentifier.getName());
                }
            } else {
                acctInfo = managerInst.readAccountFedInfo(userID, searchDomain, opaqueHandle);
                if (acctInfo == null || !acctInfo.isFedStatusActive()) {
                    acctInfo = managerInst.readAccountFedInfo(userID, remoteEntityId, opaqueHandle);
                }
                if (acctInfo.isRoleIDP()) {
                    if (isSPEmpty) {
                        // set spNI to null since is empty
                        newAcctInfo = new FSAccountFedInfo(remoteEntityId, null, idpNameIdentifier, acctInfo.isRoleIDP());
                        newAcctInfo.setAffiliation(acctInfo.getAffiliation());
                        newAcctKey = new FSAccountFedInfoKey(remoteEntityId, idpNameIdentifier.getName());
                    } else {
                        newAcctInfo = new FSAccountFedInfo(remoteEntityId, spNameIdentifier, idpNameIdentifier, acctInfo.isRoleIDP());
                        newAcctInfo.setAffiliation(acctInfo.getAffiliation());
                        newAcctKey = new FSAccountFedInfoKey(hostedEntityId, spNameIdentifier.getName());
                    }
                } else {
                    newAcctInfo = new FSAccountFedInfo(remoteEntityId, idpNameIdentifier, spNameIdentifier, acctInfo.isRoleIDP());
                    newAcctInfo.setAffiliation(acctInfo.getAffiliation());
                    newAcctKey = new FSAccountFedInfoKey(hostedEntityId, idpNameIdentifier.getName());
                }
            }
        }
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("user id is " + userID);
        }
        return true;
    } catch (FSAccountMgmtException e) {
        FSUtils.debug.error("In FSNameRegistrationHandler::setUserID: ", e);
    }
    this.userID = null;
    return false;
}
Also used : FSAccountFedInfo(com.sun.identity.federation.accountmgmt.FSAccountFedInfo) HashMap(java.util.HashMap) SPProvidedNameIdentifier(com.sun.identity.federation.message.common.SPProvidedNameIdentifier) IDPProvidedNameIdentifier(com.sun.identity.federation.message.common.IDPProvidedNameIdentifier) FSAccountFedInfoKey(com.sun.identity.federation.accountmgmt.FSAccountFedInfoKey) FSAccountMgmtException(com.sun.identity.federation.accountmgmt.FSAccountMgmtException) Map(java.util.Map) HashMap(java.util.HashMap) OldProvidedNameIdentifier(com.sun.identity.federation.message.common.OldProvidedNameIdentifier)

Example 3 with FSAccountFedInfo

use of com.sun.identity.federation.accountmgmt.FSAccountFedInfo in project OpenAM by OpenRock.

the class FSTerminationInitiationServlet method doTerminationInitiation.

/**
     * Called when a Termination needs to be initiated with a remote provider.
     * @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 where termination is initiated
     * @param hostedConfig hosted provider's extended meta
     * @param realm the realm under which the entity resides
     * @param hostedEntityId hosted provider's entity ID
     * @param hostedRole hosted provider's role
     * @param providerAlias hosted provider's meta alias
     */
private void doTerminationInitiation(HttpServletRequest request, HttpServletResponse response, ProviderDescriptorType hostedProviderDesc, BaseConfigType hostedConfig, String realm, String hostedEntityId, String hostedRole, String providerAlias) {
    FSUtils.debug.message("Entered FSTerminationInitiationServlet::doTerminationInitiation");
    try {
        Object ssoToken = getValidToken(request);
        if (ssoToken != null) {
            String remoteEntityId = request.getParameter(IFSConstants.TERMINATION_PROVIDER_ID);
            if (remoteEntityId == null || remoteEntityId.length() < 1) {
                FSUtils.debug.error("Provider Id not found, display error page");
                FSServiceUtils.showErrorPage(response, commonErrorPage, IFSConstants.TERMINATION_NO_PROVIDER, IFSConstants.CONTACT_ADMIN);
                return;
            }
            // session token is valid, ProviderId available
            FSServiceManager instSManager = FSServiceManager.getInstance();
            if (instSManager != null) {
                FSUtils.debug.message("FSServiceManager Instance not null");
                String remoteProviderRole = IFSConstants.SP;
                FSAccountFedInfo fedinfo = null;
                if (hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
                    remoteProviderRole = IFSConstants.IDP;
                    FSSessionManager sessManager = FSSessionManager.getInstance(providerAlias);
                    FSSession ssoSession = sessManager.getSession(ssoToken);
                    if (ssoSession != null) {
                        if (!ssoSession.getOneTime()) {
                            fedinfo = ssoSession.getAccountFedInfo();
                        }
                    }
                }
                FSFedTerminationHandler handlerObj = instSManager.getFedTerminationHandler(remoteEntityId, remoteProviderRole, SessionManager.getProvider().getPrincipalName(ssoToken), realm, hostedEntityId, providerAlias);
                if (handlerObj != null) {
                    handlerObj.setHostedDescriptor(hostedProviderDesc);
                    handlerObj.setHostedDescriptorConfig(hostedConfig);
                    handlerObj.setHostedProviderRole(hostedRole);
                    handlerObj.setMetaAlias(providerAlias);
                    handlerObj.setRealm(realm);
                    handlerObj.setHostedEntityId(hostedEntityId);
                    if (fedinfo != null) {
                        handlerObj.setAccountInfo(fedinfo);
                    }
                    boolean bStatus = handlerObj.handleFederationTermination(request, response, ssoToken);
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("handleFederationTermination status is : " + bStatus);
                    }
                    return;
                } else {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("Unable to get termination " + "handler. User account Not valid");
                    }
                }
            } else {
                FSUtils.debug.message("FSServiceManager Instance null");
            }
            FSServiceUtils.returnLocallyAfterOperation(response, termDoneURL, false, IFSConstants.TERMINATION_SUCCESS, IFSConstants.TERMINATION_FAILURE);
            return;
        } else {
            FSServiceUtils.redirectForAuthentication(request, response, providerAlias);
            return;
        }
    } catch (IOException e) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("IOException in doTerminationInitiation", e);
        }
    } catch (SessionException ex) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("SessionException in doTerminationInitiation", ex);
        }
    }
    FSServiceUtils.returnLocallyAfterOperation(response, termDoneURL, false, IFSConstants.TERMINATION_SUCCESS, IFSConstants.TERMINATION_FAILURE);
    return;
}
Also used : FSServiceManager(com.sun.identity.federation.services.FSServiceManager) FSAccountFedInfo(com.sun.identity.federation.accountmgmt.FSAccountFedInfo) FSSession(com.sun.identity.federation.services.FSSession) SessionException(com.sun.identity.plugin.session.SessionException) IOException(java.io.IOException) FSSessionManager(com.sun.identity.federation.services.FSSessionManager)

Example 4 with FSAccountFedInfo

use of com.sun.identity.federation.accountmgmt.FSAccountFedInfo in project OpenAM by OpenRock.

the class FSNameRegistrationHandler method doCommonRegistration.

/**
     * Performs the operations on the users federated account at both the SP 
     * side, IDP side. The input parameters are generated
     * at SP side and at the IDP side it is retrieved from the request received.
     * @return <code>true</code> if the operation succeeded; <code>false</code>
     *  otherwise.
     */
private boolean doCommonRegistration() {
    try {
        // Get userID
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("user id is " + userID);
            FSUtils.debug.message("To write account fed info to DS");
        }
        if (oldAcctKey != null) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("Old Account Key : " + oldAcctKey);
            }
            String oldNameIDValue = oldAcctKey.getName();
            FSAccountFedInfo oldInfo = managerInst.readAccountFedInfo(userID, remoteEntityId, oldNameIDValue);
            if (oldInfo != null) {
                managerInst.removeAccountFedInfo(userID, oldInfo);
            }
            managerInst.writeAccountFedInfo(userID, newAcctKey, newAcctInfo, oldAcctKey);
        } else {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("Old Account Key : " + oldAcctKey);
            }
            if (acctInfo != null) {
                managerInst.removeAccountFedInfo(userID, acctInfo);
            }
            managerInst.writeAccountFedInfo(userID, newAcctKey, newAcctInfo);
        }
        if ((ssoToken != null) && (hostedProviderRole.equalsIgnoreCase(IFSConstants.SP))) {
            FSSessionManager sessManager = FSSessionManager.getInstance(metaAlias);
            FSSession ssoSession = sessManager.getSession(ssoToken);
            if (ssoSession != null) {
                ssoSession.setAccountFedInfo(newAcctInfo);
            }
        }
        return true;
    } catch (FSAccountMgmtException e) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("Error when writing user information:", e);
        }
        return false;
    }
}
Also used : FSAccountFedInfo(com.sun.identity.federation.accountmgmt.FSAccountFedInfo) FSSession(com.sun.identity.federation.services.FSSession) FSSessionManager(com.sun.identity.federation.services.FSSessionManager) FSAccountMgmtException(com.sun.identity.federation.accountmgmt.FSAccountMgmtException)

Example 5 with FSAccountFedInfo

use of com.sun.identity.federation.accountmgmt.FSAccountFedInfo in project OpenAM by OpenRock.

the class FSNameRegistrationHandler method createNameRegistrationRequest.

/**
     * Generates the Name Registration request.
     * @return FSNameRegistrationRequest
     */
private FSNameRegistrationRequest createNameRegistrationRequest(FSAccountFedInfo acctInfo) {
    try {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("Entered FSNameRegistrationHandler:: " + "createNameRegistrationRequest");
        }
        FSNameRegistrationRequest reqName = new FSNameRegistrationRequest();
        if (reqName != null) {
            reqName.setProviderId(hostedEntityId);
            if (acctInfo.isRoleIDP()) {
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("calling of generateNameIdentifier Role : IdP ? " + acctInfo.isRoleIDP());
                }
                NameIdentifier nameIdentifier = generateNameIdentifier();
                if (acctInfo.getAffiliation()) {
                    String affiliationID = FSServiceUtils.getAffiliationID(realm, remoteEntityId);
                    if (affiliationID != null) {
                        nameIdentifier.setNameQualifier(affiliationID);
                    }
                } else {
                    nameIdentifier.setNameQualifier(hostedEntityId);
                }
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("out of generateNameIdentifier ****" + "\nNew SP nameIdentifier Qualifier: " + nameIdentifier.getNameQualifier() + "\nNew SP nameIdentifier Name :" + nameIdentifier.getName());
                }
                SPProvidedNameIdentifier newNameIdenifier = new SPProvidedNameIdentifier(nameIdentifier.getName(), nameIdentifier.getNameQualifier(), nameIdentifier.getFormat());
                NameIdentifier remoteIdentifier = acctInfo.getRemoteNameIdentifier();
                NameIdentifier localIdentifier = acctInfo.getLocalNameIdentifier();
                reqName.setIDPProvidedNameIdentifier(new IDPProvidedNameIdentifier(remoteIdentifier.getName(), remoteIdentifier.getNameQualifier(), remoteIdentifier.getFormat()));
                reqName.setSPProvidedNameIdentifier(newNameIdenifier);
                if (localIdentifier != null) {
                    reqName.setOldProvidedNameIdentifier(new OldProvidedNameIdentifier(localIdentifier.getName(), localIdentifier.getNameQualifier(), localIdentifier.getFormat()));
                    try {
                        oldAcctKey = new FSAccountFedInfoKey(localIdentifier.getNameQualifier(), localIdentifier.getName());
                    } catch (FSAccountMgmtException e) {
                        oldAcctKey = null;
                    }
                } else {
                    // when Service Provider sends the name reg. request 
                    // for the first time, OldProvidedNameIdentifier is
                    // same as the IDPProvidedNameIdentifier as per the spec
                    reqName.setOldProvidedNameIdentifier(new OldProvidedNameIdentifier(remoteIdentifier.getName(), remoteIdentifier.getNameQualifier(), remoteIdentifier.getFormat()));
                    try {
                        oldAcctKey = new FSAccountFedInfoKey(remoteIdentifier.getNameQualifier(), remoteIdentifier.getName());
                    } catch (FSAccountMgmtException e) {
                        oldAcctKey = null;
                    }
                }
                try {
                    FSAccountFedInfoKey tmpKey = new FSAccountFedInfoKey(nameIdentifier.getNameQualifier(), nameIdentifier.getName());
                    FSAccountFedInfo tmpInfo = new FSAccountFedInfo(remoteEntityId, newNameIdenifier, remoteIdentifier, acctInfo.isRoleIDP());
                    tmpInfo.setAffiliation(acctInfo.getAffiliation());
                    returnMap.put("userID", userID);
                    returnMap.put("OldAccountKey", oldAcctKey);
                    if (oldAcctKey != null) {
                        if (FSUtils.debug.messageEnabled()) {
                            FSUtils.debug.message("Get OldAcctKet Name : " + oldAcctKey.getName() + "\nGet OldAcctKet Qualifier : " + oldAcctKey.getNameSpace());
                        }
                    } else {
                        FSUtils.debug.message("OldAccount Key is null");
                    }
                    returnMap.put("AccountKey", tmpKey);
                    returnMap.put("AccountInfo", tmpInfo);
                    returnMap.put("RegisSource", regisSource);
                    returnMap.put(IFSConstants.LRURL, returnURL);
                } catch (FSAccountMgmtException e) {
                    return null;
                }
            } else {
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("calling of generateNameIdenti" + "fier Role : IdP ? " + acctInfo.isRoleIDP());
                }
                NameIdentifier nameIdentifier = generateNameIdentifier();
                if (acctInfo.getAffiliation()) {
                    String affiliationID = FSServiceUtils.getAffiliationID(realm, remoteEntityId);
                    if (affiliationID != null) {
                        nameIdentifier.setNameQualifier(affiliationID);
                    }
                }
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("New IDP nameIdentifier Name : " + nameIdentifier.getName() + "\nNew IDP nameIdentifier Qualifier :" + nameIdentifier.getNameQualifier() + "out of generateNameIdentifier*****");
                }
                IDPProvidedNameIdentifier newNameIdenifier = new IDPProvidedNameIdentifier(nameIdentifier.getName(), nameIdentifier.getNameQualifier(), nameIdentifier.getFormat());
                NameIdentifier remoteIdentifier = // SP
                acctInfo.getRemoteNameIdentifier();
                NameIdentifier localIdentifier = // IdP
                acctInfo.getLocalNameIdentifier();
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("Old IDP nameIdentifier Name : " + localIdentifier.getName() + "\nOld IDP nameIdentifier Qualifier :" + localIdentifier.getNameQualifier());
                }
                FSUtils.debug.message("To set OldProvidedNameIdentifier");
                reqName.setOldProvidedNameIdentifier(new OldProvidedNameIdentifier(localIdentifier.getName(), localIdentifier.getNameQualifier(), localIdentifier.getFormat()));
                FSUtils.debug.message("To set IdpProvidedNameIdentifier");
                reqName.setIDPProvidedNameIdentifier(newNameIdenifier);
                if (remoteIdentifier != null) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("SP nameIdentifier Name : " + remoteIdentifier.getName() + "SP nameIdentifier Qualifier :" + remoteIdentifier.getNameQualifier());
                    }
                    SPProvidedNameIdentifier spNameIdentifier = new SPProvidedNameIdentifier(remoteIdentifier.getName(), remoteIdentifier.getNameQualifier(), remoteIdentifier.getFormat());
                    reqName.setSPProvidedNameIdentifier(spNameIdentifier);
                }
                try {
                    oldAcctKey = new FSAccountFedInfoKey(hostedEntityId, localIdentifier.getName());
                    FSAccountFedInfoKey tmpKey = new FSAccountFedInfoKey(nameIdentifier.getNameQualifier(), nameIdentifier.getName());
                    FSAccountFedInfo tmpInfo = new FSAccountFedInfo(remoteEntityId, newNameIdenifier, remoteIdentifier, acctInfo.isRoleIDP());
                    returnMap.put("userID", userID);
                    returnMap.put("OldAccountKey", oldAcctKey);
                    returnMap.put("AccountKey", tmpKey);
                    returnMap.put("AccountInfo", tmpInfo);
                    returnMap.put("RegisSource", regisSource);
                    returnMap.put(IFSConstants.LRURL, returnURL);
                    if (oldAcctKey != null) {
                        if (FSUtils.debug.messageEnabled()) {
                            FSUtils.debug.message("Get OldAcctKet Name : " + oldAcctKey.getName() + "\nGet OldAcctKet Qualifier: " + oldAcctKey.getNameSpace());
                        }
                    } else {
                        FSUtils.debug.message("OldAccount Key is null");
                    }
                } catch (FSAccountMgmtException e) {
                    return null;
                }
            }
            reqName.setMinorVersion(FSServiceUtils.getMinorVersion(remoteDescriptor.getProtocolSupportEnumeration()));
            return reqName;
        }
    } catch (SAMLException e) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("got SAMLException:", e);
        }
    }
    return null;
}
Also used : FSAccountFedInfo(com.sun.identity.federation.accountmgmt.FSAccountFedInfo) NameIdentifier(com.sun.identity.saml.assertion.NameIdentifier) IDPProvidedNameIdentifier(com.sun.identity.federation.message.common.IDPProvidedNameIdentifier) SPProvidedNameIdentifier(com.sun.identity.federation.message.common.SPProvidedNameIdentifier) OldProvidedNameIdentifier(com.sun.identity.federation.message.common.OldProvidedNameIdentifier) SPProvidedNameIdentifier(com.sun.identity.federation.message.common.SPProvidedNameIdentifier) FSNameRegistrationRequest(com.sun.identity.federation.message.FSNameRegistrationRequest) IDPProvidedNameIdentifier(com.sun.identity.federation.message.common.IDPProvidedNameIdentifier) FSAccountFedInfoKey(com.sun.identity.federation.accountmgmt.FSAccountFedInfoKey) FSAccountMgmtException(com.sun.identity.federation.accountmgmt.FSAccountMgmtException) SAMLException(com.sun.identity.saml.common.SAMLException) OldProvidedNameIdentifier(com.sun.identity.federation.message.common.OldProvidedNameIdentifier)

Aggregations

FSAccountFedInfo (com.sun.identity.federation.accountmgmt.FSAccountFedInfo)21 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)12 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)10 SessionException (com.sun.identity.plugin.session.SessionException)10 NameIdentifier (com.sun.identity.saml.assertion.NameIdentifier)10 IOException (java.io.IOException)10 FSAccountFedInfoKey (com.sun.identity.federation.accountmgmt.FSAccountFedInfoKey)9 FSSession (com.sun.identity.federation.services.FSSession)8 FSSessionManager (com.sun.identity.federation.services.FSSessionManager)8 SAMLException (com.sun.identity.saml.common.SAMLException)8 HashMap (java.util.HashMap)7 FSAccountManager (com.sun.identity.federation.accountmgmt.FSAccountManager)6 SessionProvider (com.sun.identity.plugin.session.SessionProvider)6 Map (java.util.Map)6 FSException (com.sun.identity.federation.common.FSException)5 SAMLResponderException (com.sun.identity.saml.common.SAMLResponderException)4 FSLogoutNotification (com.sun.identity.federation.message.FSLogoutNotification)3 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)3 FSSessionPartner (com.sun.identity.federation.services.FSSessionPartner)3 Set (java.util.Set)3