Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
<groupId>com.epimorphics</groupId>
<artifactId>appbase-security</artifactId>
<packaging>jar</packaging>
<version>3.0.6-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
<name>Appbase security</name>
<url>http://maven.apache.org</url>

<scm>
<developerConnection>scm:git:git@github.com:epimorphics/appbase-security.git</developerConnection>
Expand Down Expand Up @@ -68,7 +67,7 @@
<dependency>
<groupId>com.epimorphics</groupId>
<artifactId>appbase</artifactId>
<version>3.1.14</version>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.openid4java</groupId>
Expand Down Expand Up @@ -99,22 +98,35 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.14.3.0</version>
<version>10.17.1.0</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>10.17.1.0</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.21</version>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand All @@ -134,6 +146,11 @@
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.20.0</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -145,8 +162,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>21</source>
<target>21</target>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.List;
import java.util.Set;

import org.apache.jena.riot.system.stream.StreamManager;
import org.apache.shiro.util.ByteSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -71,8 +72,7 @@ public void setDbfile(String dbfile) {

protected boolean initstore() {
try {
Class.forName(driver).newInstance();

Class.forName(driver).getDeclaredConstructor().newInstance();
conn = DriverManager.getConnection(protocol + dbfile + ";create=true");

ResultSet tables = conn.getMetaData().getTables(null, null, null, new String[]{"TABLE"});
Expand Down Expand Up @@ -353,4 +353,4 @@ public void shutdown() {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import java.util.List;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
Expand Down Expand Up @@ -191,7 +191,6 @@ static public String verifyResponse(HttpServletRequest request, HttpServletRespo
String provider = (String)session.getAttribute(SA_OPENID_PROVIDER);
if (provider != null && !provider.isEmpty()) {
Cookie cookie = new Cookie(PROVIDER_COOKIE, provider);
cookie.setComment("Records the openid provider you last used to log in to an appbase application");
cookie.setMaxAge(60 * 60 * 24 * 30);
cookie.setHttpOnly(true);
cookie.setPath("/");
Expand Down
18 changes: 10 additions & 8 deletions src/test/java/com/epimorphics/appbase/security/TestRealm.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@

package com.epimorphics.appbase.security;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.env.BasicIniEnvironment;
import org.apache.shiro.env.Environment;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.Factory;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class TestRealm {

@Test
public void testRealmControls() {
// Set up Shiro from ini file
Factory<SecurityManager> factory = new IniSecurityManagerFactory("file:test/shiro.ini");
SecurityManager securityManager = factory.getInstance();
Environment env = new BasicIniEnvironment("file:test/shiro.ini");
SecurityManager securityManager = env.getSecurityManager();
// Factory<SecurityManager> factory = new IniSecurityManagerFactory("file:test/shiro.ini");
// SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
AppRealm realm = AppRealm.getRealm();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

package com.epimorphics.appbase.security;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

import java.util.List;
import java.util.Set;

import org.apache.shiro.authc.SaltedAuthenticationInfo;
import org.apache.shiro.util.ByteSource;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import com.epimorphics.appbase.security.BaseUserStore.UserRecord;

Expand Down
14 changes: 14 additions & 0 deletions src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%5p [%t] %logger - %m%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
<logger name="org.apache.jena" level="INFO"/>
<logger name="org.apache.shiro.realm" level="INFO"/>
</configuration>
Loading