Skip to content

Commit

Permalink
wip: all compiler warnings fixed, TODO maven warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lprimak committed Dec 20, 2023
1 parent 702aede commit 807b360
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 16 deletions.
6 changes: 3 additions & 3 deletions samples/quickstart/src/main/java/Quickstart.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.env.BasicIniEnvironment;
import org.apache.shiro.ini.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.Session;
Expand Down Expand Up @@ -46,14 +47,13 @@ public static void main(String[] args) {

// Use the shiro.ini file at the root of the classpath
// (file: and url: prefixes load from files and urls respectively):
Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini");
SecurityManager securityManager = factory.getInstance();
SecurityManager securityManager = new BasicIniEnvironment("classpath:shiro.ini").getSecurityManager();

// for this simple example quickstart, make the SecurityManager
// accessible as a JVM singleton. Most applications wouldn't do this
// and instead rely on their container configuration or web.xml for
// webapps. That is outside the scope of this simple quickstart, so
// we'll just do the bare minimum so you can continue to get a feel
// we'll just do the bare minimum, so you can continue to get a feel
// for things.
SecurityUtils.setSecurityManager(securityManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
*/
package org.apache.shiro.samples.sprhib.dao;

import org.apache.shiro.lang.util.Assert;
import org.apache.shiro.samples.sprhib.model.User;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

import java.util.List;

Expand All @@ -35,7 +35,7 @@ public User getUser(Long userId) {
public User findUser(String username) {
Assert.hasText(username);
String query = "from User u where u.username = :username";
return (User) getSession().createQuery(query).setString("username", username).uniqueResult();
return (User) getSession().createQuery(query).setParameter("username", username).uniqueResult();
}

public void createUser(User user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Index;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinTable;
import javax.persistence.Table;
import java.util.Set;
Expand All @@ -36,7 +36,9 @@
* Model object that represents a security role.
*/
@Entity
@Table(name = "roles")
@Table(name = "roles", indexes = {
@Index(name = "idx_roles_name", columnList = "name")
})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Role {

Expand Down Expand Up @@ -68,7 +70,6 @@ public void setId(Long id) {

@Basic(optional = false)
@Column(length = 100)
@Index(name = "idx_roles_name")
public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Index;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
Expand All @@ -43,7 +43,9 @@
* does in fact do this for your reference (see User.hbm.xml - the 'roles' declaration).</p>
*/
@Entity
@Table(name = "users")
@Table(name = "users", indexes = {
@Index(name = "idx_users_username", columnList = "username"),
@Index(name = "idx_users_email", columnList = "email")})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class User {

Expand Down Expand Up @@ -71,7 +73,6 @@ public void setId(Long id) {
*/
@Basic(optional = false)
@Column(length = 100)
@Index(name = "idx_users_username")
public String getUsername() {
return username;
}
Expand All @@ -81,7 +82,6 @@ public void setUsername(String username) {
}

@Basic(optional = false)
@Index(name = "idx_users_email")
public String getEmail() {
return email;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.Sha256CredentialsMatcher;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class SampleRealm extends AuthorizingRealm {
public SampleRealm() {
//This name must match the name in the User class's getPrincipals() method
setName("SampleRealm");
setCredentialsMatcher(new Sha256CredentialsMatcher());
setCredentialsMatcher(new SimpleCredentialsMatcher());
}

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.apache.shiro.samples.sprhib.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand All @@ -34,7 +34,7 @@
* cached in the Hibernate second-level cache.
*/
@Component
public class CurrentUserInterceptor extends HandlerInterceptorAdapter {
public class CurrentUserInterceptor implements HandlerInterceptor {

private UserService userService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public class RemotingServletConfig {

@Bean(name = "/sampleManager")
@SuppressWarnings("deprecation")
public HttpInvokerServiceExporter accountServiceExporter(SampleManager sampleManager,
SecureRemoteInvocationExecutor secureRemoteInvocationExecutor) {

Expand Down

0 comments on commit 807b360

Please sign in to comment.