Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dariah
dariahsp
Commits
bd14ce93
Commit
bd14ce93
authored
Mar 24, 2017
by
Gradl, Tobias
Browse files
700: Migrate from old SP libraries to consolidated version
Task-Url:
https://minfba.de.dariah.eu/mantisbt/view.php?id=700
parent
ae1748c8
Changes
7
Hide whitespace changes
Inline
Side-by-side
dariahsp-core/pom.xml
View file @
bd14ce93
...
...
@@ -35,6 +35,15 @@
<version>
1.0.3-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
<version>
3.1.0
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
<distributionManagement>
...
...
dariahsp-core/src/main/java/eu/dariah/de/dariahsp/model/Role.java
0 → 100644
View file @
bd14ce93
package
eu.dariah.de.dariahsp.model
;
import
org.springframework.security.core.GrantedAuthority
;
public
interface
Role
extends
GrantedAuthority
{
public
int
getId
();
public
int
getLevel
();
public
String
getDescription
();
}
dariahsp-core/src/main/java/eu/dariah/de/dariahsp/model/SimpleUserDetails.java
0 → 100644
View file @
bd14ce93
package
eu.dariah.de.dariahsp.model
;
import
java.util.Collection
;
import
org.springframework.security.core.userdetails.UserDetails
;
public
class
SimpleUserDetails
implements
UserDetails
,
StagedUserDetails
{
private
static
final
long
serialVersionUID
=
-
1504226378983075730L
;
private
Collection
<
Role
>
authorities
;
protected
String
id
;
private
String
endpointId
;
private
String
endpointName
;
private
String
username
;
private
boolean
expired
;
private
String
language
;
private
boolean
hasAllAttributes
;
public
SimpleUserDetails
()
{}
public
SimpleUserDetails
(
User
user
,
Collection
<
Role
>
authorities
)
{
this
.
id
=
user
.
getId
();
this
.
username
=
user
.
getNameId
();
this
.
expired
=
user
.
isExpired
();
this
.
endpointId
=
user
.
getEndpointId
();
this
.
language
=
user
.
getLanguage
();
this
.
authorities
=
authorities
;
this
.
endpointName
=
user
.
getEndpointName
();
this
.
hasAllAttributes
=
false
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getEndpointId
()
{
return
endpointId
;
}
public
void
setEndpointId
(
String
endpointId
)
{
this
.
endpointId
=
endpointId
;
}
public
String
getEndpointName
()
{
return
endpointName
;
}
public
void
setEndpointName
(
String
endpointName
)
{
this
.
endpointName
=
endpointName
;
}
public
boolean
isExpired
()
{
return
expired
;
}
public
void
setExpired
(
boolean
expired
)
{
this
.
expired
=
expired
;
}
public
String
getLanguage
()
{
return
language
;
}
public
void
setLanguage
(
String
language
)
{
this
.
language
=
language
;
}
public
boolean
isHasAllAttributes
()
{
return
hasAllAttributes
;
}
public
void
setHasAllAttributes
(
boolean
hasAllAttributes
)
{
this
.
hasAllAttributes
=
hasAllAttributes
;
}
public
void
setAuthorities
(
Collection
<
Role
>
authorities
)
{
this
.
authorities
=
authorities
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getUsername
()
{
return
username
;
}
public
String
getPassword
()
{
return
""
;
}
public
Collection
<
Role
>
getAuthorities
()
{
return
authorities
;
}
public
boolean
isAccountNonExpired
()
{
return
!
expired
;
}
public
boolean
isAccountNonLocked
()
{
return
!
expired
;
}
public
boolean
isCredentialsNonExpired
()
{
return
!
expired
;
}
public
boolean
isEnabled
()
{
return
!
expired
;
}
public
int
getMaxAuthorityLevel
()
{
int
level
=
0
;
if
(
getAuthorities
()
!=
null
)
{
for
(
Role
auth
:
getAuthorities
())
{
if
(
auth
instanceof
Role
&&
((
Role
)
auth
).
getLevel
()
>
level
)
{
level
=
((
Role
)
auth
).
getLevel
();
}
}
}
return
level
;
}
public
boolean
isAuthorized
(
Role
compRole
)
{
return
getMaxAuthorityLevel
()
>=
compRole
.
getLevel
();
}
}
\ No newline at end of file
dariahsp-core/src/main/java/eu/dariah/de/dariahsp/model/StagedUserDetails.java
0 → 100644
View file @
bd14ce93
package
eu.dariah.de.dariahsp.model
;
public
interface
StagedUserDetails
{
public
int
getMaxAuthorityLevel
();
public
boolean
isAuthorized
(
Role
compRole
);
}
dariahsp-core/src/main/java/eu/dariah/de/dariahsp/model/User.java
0 → 100644
View file @
bd14ce93
package
eu.dariah.de.dariahsp.model
;
public
interface
User
{
public
String
getId
();
public
String
getNameId
();
public
boolean
isExpired
();
public
String
getEndpointId
();
public
String
getEndpointName
();
public
String
getLanguage
();
}
dariahsp-core/src/main/java/eu/dariah/de/dariahsp/
web/
model/AuthPojo.java
→
dariahsp-core/src/main/java/eu/dariah/de/dariahsp/model/
web/
AuthPojo.java
View file @
bd14ce93
package
eu.dariah.de.dariahsp.
web.
model
;
package
eu.dariah.de.dariahsp.model
.web
;
import
java.util.List
;
...
...
dariahsp-core/src/main/java/eu/dariah/de/dariahsp/web/helper/AuthInfoHelper.java
View file @
bd14ce93
...
...
@@ -8,8 +8,9 @@ import org.springframework.security.core.GrantedAuthority;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.User
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
de.dariah.aai.javasp.base.SimpleUserDetails
;
import
eu.dariah.de.dariahsp.web.model.AuthPojo
;
import
eu.dariah.de.dariahsp.model.SimpleUserDetails
;
import
eu.dariah.de.dariahsp.model.web.AuthPojo
;
public
class
AuthInfoHelper
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment