Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
<resolver:AttributeDefinition id="norEduPersonNIN" xsi:type="Script" xmlns="urn:mace:shibboleth:2.0:resolver:ad">
        <resolver:Dependency ref="myLDAP" />
        <resolver:AttributeEncoder xsi:type="enc:SAML1String"
                name="urn:mace:dir:attribute-def:norEduPersonNIN" />
        <resolver:AttributeEncoder xsi:type="enc:SAML2String"
                name="urn:oid:1.3.6.1.4.1.2428.90.1.5" friendlyName="norEduPersonNIN" />
        <Script>
                <![CDATA[
               // Script to handle 10 position wide national identity numbers
               // Create 12 position wide norEduPersonNIN from the attribute mittPersonnummer
               // Change employeeNumber to your NIN attribute name
                        try {
                                // Get a ref to the NIN received from ldap
                                // Change mittPersonnummer to your NIN attribute name
                                nin=employeeNumber.getValues().get(0);
                                // Only do decoration of NINs which are on the format YYMMDDxxxx
                                if(nin.length() == 10) {
                                        // Create the two alternative return strings we have to choose between
                                        pnr19 = "19" + nin;
                                        pnr20 = "20" + nin;
                                        // Extract year/month/day from the NIN string
                                        m_y = nin.substring(0,2);
                                        m_m = nin.substring(2,4);
                                        m_d = nin.substring(4,6);
                                        // Create a Date object for the 20xx case
                                        datePnr = new Date("20" + m_y, m_m-1, m_d);
                                        // Create a Date object for the current date
                                        dateCur = new Date();
                                        // Verify the value of datePnr before proceeding
                                        if(isNaN(datePnr.valueOf())) {
                                                throw("Failed to parse the NIN into a Date object");
                                        }
                                        // If the 20xx case is in the future we assume 19xx for the NIN attribute
                                        if(datePnr>dateCur) {
                                                norEduPersonNIN.getValues().add(pnr19);
                                        } else {
                                                norEduPersonNIN.getValues().add(pnr20);
                                        }
                                } else if(nin.length() == 12) {
                                        norEduPersonNIN.getValues().add(nin);
                                } else {
                                        throw("Not setting any norEduPersonNIN since it is bogus (length=" + nin.length() + "): " + nin);
                                }
                        }
                        catch(err) {
                                throw("Not setting any norEduPersonNIN due to exception: " + err);
                        }
                ]]>
        </Script>
</resolver:AttributeDefinition>

schacDateOfBirth


Förutsättningar:

  • Personnumret finns i norEduPersonNIN i format ÅÅÅÅMMDD
Code Block
languagexml
    <AttributeDefinition xsi:type="RegexSplit" id="schacDateOfBirth" regex="^(.{8}).*$">
        <InputDataConnector ref="norEduPersonNIN" />
        <AttributeEncoder xsi:type="SAML1String" name="urn:mace:dir:attribute-def:schacDateOfBirth" encodeType="false" />
        <AttributeEncoder xsi:type="SAML2String" name="urn:oid:1.3.6.1.4.1.25178.1.2.3" friendlyName="schacDateOfBirth" encodeType="false" />
    </AttributeDefinition>