Skip to content

Commit

Permalink
Upgraded github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Nov 13, 2023
1 parent c6ccd69 commit 67d5736
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
cache: 'maven'

- name: Build with Maven
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
cache: 'maven'
server-id: openconext-releases
server-username: MAVEN_USERNAME
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

### [Usage](#usage)

The main interface of the SAML IdP library is `SAMLIdPService`.
It provides the following functionality
The main interface of the SAML library is `SAMLService`.
It provides the following functionality:
- parsing SAML to an `org.opensaml.saml.saml2.core.AuthnRequest`
- sending SAML response back to the Service Provider
- construct the IdP metadata
- resolve the SigningCredential of a Service Provider based on the metadata URL

### [Crypto](#crypto)

The saml-idp library uses a private RSA key and corresponding certificate to sign the SAML requests. If you want to
The saml-java library uses a private RSA key and corresponding certificate to sign the SAML requests. If you want to
deploy the application in an environment where the certificate needs to be registered with the Service Provider (Proxy)
then you can generate a key pair with the following commands:
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
import static org.opensaml.saml.common.xml.SAMLConstants.SAML2_POST_BINDING_URI;


public class DefaultSAMLIdPService implements SAMLIdPService {
public class DefaultSAMLService implements SAMLService {

static {
java.security.Security.addProvider(
Expand All @@ -85,7 +85,7 @@ public class DefaultSAMLIdPService implements SAMLIdPService {
public static final String authnContextClassRefPassword = AuthnContext.PASSWORD_AUTHN_CTX;
public static final String authnContextClassRefUnspecified = AuthnContext.UNSPECIFIED_AUTHN_CTX;

private static final Logger LOG = LoggerFactory.getLogger(DefaultSAMLIdPService.class);
private static final Logger LOG = LoggerFactory.getLogger(DefaultSAMLService.class);

private final OpenSamlVelocityEngine velocityEngine = new OpenSamlVelocityEngine();
private final BasicParserPool parserPool;
Expand All @@ -95,7 +95,7 @@ public class DefaultSAMLIdPService implements SAMLIdPService {
private final Credential signingCredential;

@SneakyThrows
public DefaultSAMLIdPService(SAMLConfiguration configuration) {
public DefaultSAMLService(SAMLConfiguration configuration) {
SAMLIdentityProvider identityProvider = configuration.getIdentityProvider();
String entityId = identityProvider.getEntityId();
String secret = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import javax.servlet.http.HttpServletResponse;
import java.util.List;

public interface SAMLIdPService {
public interface SAMLService {


AuthnRequest createAuthnRequest(String authnContextClassRef);

/**
* Parse XML String to {@link Response}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.opensaml.core.criterion.EntityIdCriterion;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.schema.XSString;
import org.opensaml.core.xml.util.XMLObjectSupport;
import org.opensaml.saml.saml2.core.Assertion;
Expand Down Expand Up @@ -47,15 +46,15 @@
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.junit.jupiter.api.Assertions.*;

class DefaultSAMLIdPServiceTest {
class DefaultSAMLServiceTest {

private static final SimpleDateFormat issueFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
private static final String spEntityId = "https://engine.test.surfconext.nl/authentication/sp/metadata";
private static final Credential signingCredential;

@RegisterExtension
WireMockExtension mockServer = new WireMockExtension(8999);
private DefaultSAMLIdPService samlIdPService;
private DefaultSAMLService samlIdPService;

static {
java.security.Security.addProvider(
Expand All @@ -78,7 +77,7 @@ class DefaultSAMLIdPServiceTest {
@BeforeEach
void beforeEach() {
SAMLConfiguration samlConfiguration = getSamlConfiguration(false);
samlIdPService = new DefaultSAMLIdPService(samlConfiguration);
samlIdPService = new DefaultSAMLService(samlConfiguration);
}

private String getSPMetaData() {
Expand All @@ -93,7 +92,7 @@ private String getSPMetaData() {
SAMLServiceProvider serviceProvider = new SAMLServiceProvider(spEntityId, spEntityId);
serviceProvider.setCredential(signingCredential);
serviceProvider.setAcsLocation("https://engine.test.surfconext.nl/authentication/sp/consume-assertion");
DefaultSAMLIdPService tempSamlIdPService = new DefaultSAMLIdPService(samlConfiguration);
DefaultSAMLService tempSamlIdPService = new DefaultSAMLService(samlConfiguration);
return tempSamlIdPService.serviceProviderMetaData(serviceProvider);
}

Expand Down Expand Up @@ -140,7 +139,7 @@ private String signedSamlAuthnRequest() {

@SneakyThrows
private static String readFile(String path) {
InputStream inputStream = DefaultSAMLIdPService.class.getClassLoader().getResourceAsStream(path);
InputStream inputStream = DefaultSAMLService.class.getClassLoader().getResourceAsStream(path);
return IOUtils.toString(inputStream, Charset.defaultCharset());
}

Expand All @@ -166,7 +165,7 @@ void parseAuthnRequest() {
@Test
void parseAuthnRequestSignatureMissing() {
SAMLConfiguration samlConfiguration = getSamlConfiguration(true);
DefaultSAMLIdPService idPService = new DefaultSAMLIdPService(samlConfiguration);
DefaultSAMLService idPService = new DefaultSAMLService(samlConfiguration);
String samlRequest = this.samlAuthnRequest();

assertThrows(SignatureException.class, () -> idPService.parseAuthnRequest(samlRequest, true, true));
Expand Down Expand Up @@ -213,7 +212,7 @@ void sendResponse() {
SAMLStatus.SUCCESS,
"relayState😀",
null,
DefaultSAMLIdPService.authnContextClassRefPassword,
DefaultSAMLService.authnContextClassRefPassword,
List.of(
new SAMLAttribute("group", "riders"),
new SAMLAttribute("group", "gliders"),
Expand Down Expand Up @@ -266,7 +265,7 @@ void sendResponseNoAuthnContext() {
SAMLStatus.NO_AUTHN_CONTEXT,
null,
"Not Ok",
DefaultSAMLIdPService.authnContextClassRefPassword,
DefaultSAMLService.authnContextClassRefPassword,
List.of(),
httpServletResponse
);
Expand Down

0 comments on commit 67d5736

Please sign in to comment.