Search in sources :

Example 1 with SPProvidedNameIdentifier

use of com.sun.identity.federation.message.common.SPProvidedNameIdentifier 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 2 with SPProvidedNameIdentifier

use of com.sun.identity.federation.message.common.SPProvidedNameIdentifier 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)

Example 3 with SPProvidedNameIdentifier

use of com.sun.identity.federation.message.common.SPProvidedNameIdentifier in project OpenAM by OpenRock.

the class FSNameRegistrationRequest method parseURLEncodedRequest.

/**
     * Returns <code>FSNameRegistrationRequest</code> object. The
     * object is creating by parsing the <code>HttpServletRequest</code>
     * object.
     *
     * @param request the <code>HttpServletRequest</code> object.
     * @throws FSMsgException if there is an error
     *         creating this object.
     * @throws SAMLException if there is an error.
     */
public static FSNameRegistrationRequest parseURLEncodedRequest(HttpServletRequest request) throws FSMsgException, SAMLException {
    FSNameRegistrationRequest retNameRegistrationRequest = new FSNameRegistrationRequest();
    try {
        FSUtils.debug.message("checking minor version");
        retNameRegistrationRequest.majorVersion = Integer.parseInt(request.getParameter("MajorVersion"));
        retNameRegistrationRequest.minorVersion = Integer.parseInt(request.getParameter("MinorVersion"));
    } catch (NumberFormatException ex) {
        FSUtils.debug.error("FSNameRegistrationRequest.parseURLEncoded" + "Request: Invalid versions", ex);
        throw new FSMsgException("invalidNumber", null);
    }
    FSUtils.debug.message("checking RequestID");
    if (request.getParameter("RequestID") != null) {
        retNameRegistrationRequest.requestID = request.getParameter("RequestID");
    } else {
        FSUtils.debug.error("FSNameRegistrationRequest.parseURLEncoded" + "Request: RequestID not found");
        String[] args = { IFSConstants.REQUEST_ID };
        throw new FSMsgException("missingAttribute", args);
    }
    FSUtils.debug.message("checking instantString");
    String instantString = request.getParameter("IssueInstant");
    FSUtils.debug.message("instantString : " + instantString);
    if (instantString == null || instantString.length() == 0) {
        FSUtils.debug.error("FSNameRegistrationRequest.parseURLEncoded" + "Request: IssueInstant not found");
        String[] args = { IFSConstants.ISSUE_INSTANT };
        throw new FSMsgException("missingAttribute", args);
    }
    try {
        FSUtils.debug.message("calling : DateUtils.stringToDate.issueInstant");
        retNameRegistrationRequest.issueInstant = DateUtils.stringToDate(instantString);
    } catch (ParseException e) {
        FSUtils.debug.error("FSNameRegistrationRequest.parseURLEncoded" + "Request: Can not parse IssueInstant", e);
        throw new FSMsgException("parseError", null);
    }
    if (request.getParameter("ProviderID") != null) {
        retNameRegistrationRequest.providerId = request.getParameter("ProviderID");
    } else {
        FSUtils.debug.error("FSNameRegistrationRequest.parseURLEncoded" + "Request: Can not find ProviderID");
        throw new FSMsgException("missingElement", null);
    }
    FSUtils.debug.message("start identifier processing");
    String spNameFormat = "";
    String spNameQualifier = "";
    String spName = "";
    if (request.getParameter("SPNameFormat") != null) {
        spNameFormat = request.getParameter("SPNameFormat");
    }
    if (request.getParameter("SPNameQualifier") != null) {
        spNameQualifier = request.getParameter("SPNameQualifier");
    }
    if (request.getParameter("SPProvidedNameIdentifier") != null) {
        spName = request.getParameter("SPProvidedNameIdentifier");
    }
    if (spName != null && !(spName.length() < 1)) {
        retNameRegistrationRequest.setSPProvidedNameIdentifier(new SPProvidedNameIdentifier(spName, spNameQualifier, spNameFormat));
    }
    String idpNameFormat = null;
    String idpNameQualifier = null;
    String idpName = null;
    if (request.getParameter("IDPNameFormat") != null) {
        idpNameFormat = request.getParameter("IDPNameFormat");
    }
    if (request.getParameter("IDPNameQualifier") != null) {
        idpNameQualifier = request.getParameter("IDPNameQualifier");
    }
    if (request.getParameter("IDPProvidedNameIdentifier") != null) {
        idpName = request.getParameter("IDPProvidedNameIdentifier");
    }
    if (idpName != null && !(idpName.length() < 1)) {
        retNameRegistrationRequest.idpProvidedNameIdentifier = new IDPProvidedNameIdentifier(idpName, idpNameQualifier, idpNameFormat);
    }
    String oldNameFormat = null;
    String oldNameQualifier = null;
    String oldName = null;
    if (request.getParameter("OldNameFormat") != null) {
        oldNameFormat = request.getParameter("OldNameFormat");
    }
    if (request.getParameter("OldNameQualifier") != null) {
        oldNameQualifier = request.getParameter("OldNameQualifier");
    }
    if (request.getParameter("OldProvidedNameIdentifier") != null) {
        oldName = request.getParameter("OldProvidedNameIdentifier");
    }
    if (oldName != null && !(oldName.length() < 1)) {
        retNameRegistrationRequest.oldProvidedNameIdentifier = new OldProvidedNameIdentifier(oldName, oldNameQualifier, oldNameFormat);
    }
    if (request.getParameter("RelayState") != null) {
        retNameRegistrationRequest.relayState = request.getParameter("RelayState");
    }
    return retNameRegistrationRequest;
}
Also used : FSMsgException(com.sun.identity.federation.message.common.FSMsgException) SPProvidedNameIdentifier(com.sun.identity.federation.message.common.SPProvidedNameIdentifier) ParseException(java.text.ParseException) IDPProvidedNameIdentifier(com.sun.identity.federation.message.common.IDPProvidedNameIdentifier) OldProvidedNameIdentifier(com.sun.identity.federation.message.common.OldProvidedNameIdentifier)

Example 4 with SPProvidedNameIdentifier

use of com.sun.identity.federation.message.common.SPProvidedNameIdentifier in project OpenAM by OpenRock.

the class FSNameRegistrationHandler method generateNameIdentifier.

/**
     * Generates the <code>SPProvidedNameIdentifier</code> that will be 
     * communicated to the IDP. The IDP will in all future communication use 
     * this Name Identifier instead of the
     * <code>IDPProvidedNameIdentifier</code>.
     * @return Service Provider generated Name identifier    
     */
private NameIdentifier generateNameIdentifier() {
    try {
        FSUtils.debug.message("Entered FSNameRegistrationHandler::generateNameIdentifier");
        NameIdentifier nameIdentifier;
        FSNameIdentifierHelper nameHelper = new FSNameIdentifierHelper(hostedConfig);
        String handleName = nameHelper.createNameIdentifier();
        if (handleName == null || handleName.trim().length() < 1) {
            FSUtils.debug.error("FSNameIdentifierHelper::createNameIdentif" + "ier returned null");
            return null;
        } else {
            FSUtils.debug.message("To set nameIdentifier");
            nameIdentifier = new NameIdentifier(handleName, remoteEntityId);
            nameIdentifier.setFormat(IFSConstants.NI_FEDERATED_FORMAT_URI);
            FSUtils.debug.message("completed set nameIdentifier");
            return nameIdentifier;
        }
    } catch (SAMLException e) {
        String[] data = { FSUtils.bundle.getString(IFSConstants.REGISTRATION_FAILED_SP_NAME_IDENTIFIER) };
        LogUtil.error(Level.INFO, "REGISTRATION_FAILED_SP_NAME_IDENTIFIER", data, ssoToken);
        return null;
    }
}
Also used : 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) SAMLException(com.sun.identity.saml.common.SAMLException) FSNameIdentifierHelper(com.sun.identity.federation.services.util.FSNameIdentifierHelper)

Aggregations

IDPProvidedNameIdentifier (com.sun.identity.federation.message.common.IDPProvidedNameIdentifier)4 OldProvidedNameIdentifier (com.sun.identity.federation.message.common.OldProvidedNameIdentifier)4 SPProvidedNameIdentifier (com.sun.identity.federation.message.common.SPProvidedNameIdentifier)4 FSAccountFedInfo (com.sun.identity.federation.accountmgmt.FSAccountFedInfo)2 FSAccountFedInfoKey (com.sun.identity.federation.accountmgmt.FSAccountFedInfoKey)2 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)2 NameIdentifier (com.sun.identity.saml.assertion.NameIdentifier)2 SAMLException (com.sun.identity.saml.common.SAMLException)2 FSNameRegistrationRequest (com.sun.identity.federation.message.FSNameRegistrationRequest)1 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)1 FSNameIdentifierHelper (com.sun.identity.federation.services.util.FSNameIdentifierHelper)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1