Skip to content

Commit 4f63246

Browse files
authored
CRISTALINT-13: Offer a way to check if the authentication service is set properly (#48)
1 parent 8ee0738 commit 4f63246

File tree

12 files changed

+239
-13
lines changed

12 files changed

+239
-13
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
-->
22+
23+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<groupId>org.xwiki.contrib.cristal.integration</groupId>
27+
<artifactId>cristal-integration</artifactId>
28+
<version>1.2.0-SNAPSHOT</version>
29+
</parent>
30+
<artifactId>cristal-integration-headless-rest-server</artifactId>
31+
<packaging>jar</packaging>
32+
<name>Cristal Integration - Headless - REST Server</name>
33+
<description>Service to allow connection from an external Cristal instance through a RESTful API</description>
34+
35+
<properties>
36+
<xwiki.extension.name>Cristal Integration - Headless - REST Server</xwiki.extension.name>
37+
<xwiki.extension.category>application</xwiki.extension.category>
38+
</properties>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>org.xwiki.contrib.cristal.integration</groupId>
43+
<artifactId>cristal-integration-rest-api</artifactId>
44+
<version>${project.version}</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.xwiki.platform</groupId>
48+
<artifactId>xwiki-platform-rest-api</artifactId>
49+
<version>${platform.version}</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.xwiki.platform</groupId>
53+
<artifactId>xwiki-platform-rest-server</artifactId>
54+
<version>${platform.version}</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.xwiki.platform</groupId>
58+
<artifactId>xwiki-platform-oldcore</artifactId>
59+
<version>${platform.version}</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>org.xwiki.contrib.oidc</groupId>
63+
<artifactId>oidc-provider</artifactId>
64+
<version>${oidc.version}</version>
65+
<scope>runtime</scope>
66+
</dependency>
67+
</dependencies>
68+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.contrib.cristal.integration.rest.internal.resources;
21+
22+
import javax.inject.Inject;
23+
import javax.inject.Named;
24+
25+
import org.xwiki.component.annotation.Component;
26+
import org.xwiki.contrib.cristal.integration.rest.resources.CristalAuthResource;
27+
import org.xwiki.rest.XWikiResource;
28+
import org.xwiki.rest.XWikiRestException;
29+
import org.xwiki.security.authservice.internal.AuthServiceConfiguration;
30+
31+
import com.xpn.xwiki.XWikiException;
32+
33+
/**
34+
* Default implementation of {@link CristalAuthResource}.
35+
*
36+
* @since 1.2.0
37+
* @version $Id$
38+
*/
39+
@Component
40+
@Named("org.xwiki.contrib.cristal.integration.rest.internal.resources.CristalAuthResourceImpl")
41+
public class CristalAuthResourceImpl extends XWikiResource implements CristalAuthResource
42+
{
43+
@Inject
44+
private AuthServiceConfiguration authServiceConfiguration;
45+
46+
@Override
47+
public String getAuthenticationService() throws XWikiRestException
48+
{
49+
try {
50+
return this.authServiceConfiguration.getAuthService();
51+
} catch (XWikiException e) {
52+
throw new XWikiRestException("Error when trying to fetch authentication service.", e);
53+
}
54+
}
55+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.xwiki.contrib.cristal.integration.rest.internal.resources.CristalAuthResourceImpl
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
-->
22+
23+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<groupId>org.xwiki.contrib.cristal.integration</groupId>
27+
<artifactId>cristal-integration</artifactId>
28+
<version>1.2.0-SNAPSHOT</version>
29+
</parent>
30+
<artifactId>cristal-integration-headless</artifactId>
31+
<packaging>jar</packaging>
32+
<name>Cristal Integration - Headless</name>
33+
<description>Configuration components to allow access to external Cristal instances</description>
34+
35+
<properties>
36+
<xwiki.extension.name>Cristal Integration - Headless</xwiki.extension.name>
37+
<xwiki.extension.category>application</xwiki.extension.category>
38+
</properties>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>org.xwiki.commons</groupId>
43+
<artifactId>xwiki-commons-component-api</artifactId>
44+
<version>${commons.version}</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.xwiki.platform</groupId>
48+
<artifactId>xwiki-platform-oldcore</artifactId>
49+
<version>${platform.version}</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.xwiki.contrib.cristal.integration</groupId>
53+
<artifactId>cristal-integration-rest-server</artifactId>
54+
<version>${project.version}</version>
55+
<scope>runtime</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.xwiki.contrib.cristal.integration</groupId>
59+
<artifactId>cristal-integration-headless-rest-server</artifactId>
60+
<version>${project.version}</version>
61+
<scope>runtime</scope>
62+
</dependency>
63+
</dependencies>
64+
</project>

cristal-integration-resource-handler/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parent>
2626
<groupId>org.xwiki.contrib.cristal.integration</groupId>
2727
<artifactId>cristal-integration</artifactId>
28-
<version>1.1.2-SNAPSHOT</version>
28+
<version>1.2.0-SNAPSHOT</version>
2929
</parent>
3030
<artifactId>cristal-integration-resource-handler</artifactId>
3131
<packaging>jar</packaging>

cristal-integration-rest-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parent>
2626
<groupId>org.xwiki.contrib.cristal.integration</groupId>
2727
<artifactId>cristal-integration</artifactId>
28-
<version>1.1.2-SNAPSHOT</version>
28+
<version>1.2.0-SNAPSHOT</version>
2929
</parent>
3030
<artifactId>cristal-integration-rest-api</artifactId>
3131
<packaging>jar</packaging>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.contrib.cristal.integration.rest.resources;
21+
22+
import javax.ws.rs.GET;
23+
import javax.ws.rs.Path;
24+
25+
import org.xwiki.rest.XWikiRestException;
26+
27+
/**
28+
* Enables a Cristal client to access the current authentication service.
29+
*
30+
* @since 1.2.0
31+
* @version $Id$
32+
*/
33+
@Path("/cristal/auth")
34+
public interface CristalAuthResource
35+
{
36+
/**
37+
* Returns the name of the current authentication service.
38+
*
39+
* @return the current authentication service
40+
*/
41+
@GET String getAuthenticationService() throws XWikiRestException;
42+
}

cristal-integration-rest-server/pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parent>
2626
<groupId>org.xwiki.contrib.cristal.integration</groupId>
2727
<artifactId>cristal-integration</artifactId>
28-
<version>1.1.2-SNAPSHOT</version>
28+
<version>1.2.0-SNAPSHOT</version>
2929
</parent>
3030
<artifactId>cristal-integration-rest-server</artifactId>
3131
<packaging>jar</packaging>
@@ -69,11 +69,5 @@
6969
<version>${markdown.version}</version>
7070
<scope>runtime</scope>
7171
</dependency>
72-
<dependency>
73-
<groupId>org.xwiki.contrib.oidc</groupId>
74-
<artifactId>oidc-provider</artifactId>
75-
<version>${oidc.version}</version>
76-
<scope>runtime</scope>
77-
</dependency>
7872
</dependencies>
7973
</project>

cristal-integration-test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parent>
2626
<groupId>org.xwiki.contrib.cristal.integration</groupId>
2727
<artifactId>cristal-integration</artifactId>
28-
<version>1.1.2-SNAPSHOT</version>
28+
<version>1.2.0-SNAPSHOT</version>
2929
</parent>
3030
<artifactId>cristal-integration-test</artifactId>
3131
<packaging>pom</packaging>

cristal-integration-ui/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parent>
2626
<groupId>org.xwiki.contrib.cristal.integration</groupId>
2727
<artifactId>cristal-integration</artifactId>
28-
<version>1.1.2-SNAPSHOT</version>
28+
<version>1.2.0-SNAPSHOT</version>
2929
</parent>
3030
<artifactId>cristal-integration-ui</artifactId>
3131
<packaging>xar</packaging>

0 commit comments

Comments
 (0)