use of org.springframework.security.saml.SAMLCredential in project webcert by sklintyg.
the class FakeElegAuthenticationProvider method createSamlCredential.
private SAMLCredential createSamlCredential(Authentication token) {
FakeElegCredentials fakeCredentials = (FakeElegCredentials) token.getCredentials();
Assertion assertion = new AssertionBuilder().buildObject();
attachAuthenticationContext(assertion, FAKE_AUTHENTICATION_ELEG_CONTEXT_REF);
AttributeStatement attributeStatement = new AttributeStatementBuilder().buildObject();
assertion.getAttributeStatements().add(attributeStatement);
attributeStatement.getAttributes().add(createAttribute(CgiElegAssertion.PERSON_ID_ATTRIBUTE, fakeCredentials.getPersonId()));
attributeStatement.getAttributes().add(createAttribute(CgiElegAssertion.FORNAMN_ATTRIBUTE, fakeCredentials.getFirstName()));
attributeStatement.getAttributes().add(createAttribute(CgiElegAssertion.MELLAN_OCH_EFTERNAMN_ATTRIBUTE, fakeCredentials.getLastName()));
NameID nameId = new NameIDBuilder().buildObject();
nameId.setValue(token.getCredentials().toString());
return new SAMLCredential(nameId, assertion, "fake-idp", "webcert");
}
use of org.springframework.security.saml.SAMLCredential in project webcert by sklintyg.
the class FakeElegAuthenticationProvider method authenticate.
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
SAMLCredential credential = createSamlCredential(authentication);
Object details = elegWebCertUserDetailsService.loadUserBySAML(credential);
ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(null, details, credential, new ArrayList<>());
result.setDetails(details);
return result;
}
use of org.springframework.security.saml.SAMLCredential in project webcert by sklintyg.
the class CommonFakeAuthenticationProvider method authenticate.
@Override
public Authentication authenticate(Authentication token) throws AuthenticationException {
SAMLCredential credential = createSamlCredential(token);
Object details = userDetails.loadUserBySAML(credential);
addAbsentAttributesFromFakeCredentials(token, details);
selectVardenhetFromFakeCredentials(token, details);
overrideSekretessMarkeringFromFakeCredentials(token, details);
updateFeatures(details);
applyUserOrigin(token, details);
applyAuthenticationMethod(token, details);
applyPersonalNumberForBankID(token, details);
ExpiringUsernameAuthenticationToken result = new ExpiringUsernameAuthenticationToken(null, details, credential, new ArrayList<>());
result.setDetails(details);
return result;
}
use of org.springframework.security.saml.SAMLCredential in project webcert by sklintyg.
the class CommonFakeAuthenticationProvider method createSamlCredential.
private SAMLCredential createSamlCredential(Authentication token) {
FakeCredentials fakeCredentials = (FakeCredentials) token.getCredentials();
Assertion assertion = new AssertionBuilder().buildObject();
attachAuthenticationContext(assertion, FAKE_AUTHENTICATION_SITHS_CONTEXT_REF);
AttributeStatement attributeStatement = new AttributeStatementBuilder().buildObject();
assertion.getAttributeStatements().add(attributeStatement);
addAttribute(attributeStatement, BaseSakerhetstjanstAssertion.HSA_ID_ATTRIBUTE, fakeCredentials.getHsaId());
NameID nameId = new NameIDBuilder().buildObject();
nameId.setValue(token.getCredentials().toString());
return new SAMLCredential(nameId, assertion, "fake-idp", "webcert");
}
use of org.springframework.security.saml.SAMLCredential in project webcert by sklintyg.
the class ElegAuthenticationAttributeHelperTest method testReadStringAttribute.
@Test
public void testReadStringAttribute() {
testee = new ElegAuthenticationAttributeHelperImpl();
SAMLCredential cred = buildPrivatlakareSamlCredential();
String personId = testee.getAttribute(cred, CgiElegAssertion.PERSON_ID_ATTRIBUTE);
assertEquals("197705232382", personId);
}
Aggregations