Polish
This commit is contained in:
parent
dba8c01035
commit
2e926601f2
|
@ -133,7 +133,7 @@ public class CrshAutoConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnExpression("'${shell.auth:simple}' == 'spring'")
|
@ConditionalOnExpression("'${shell.auth:simple}' == 'spring'")
|
||||||
@ConditionalOnMissingBean({ CrshShellAuthenticationProperties.class })
|
@ConditionalOnMissingBean({ CrshShellAuthenticationProperties.class })
|
||||||
public CrshShellAuthenticationProperties SpringAuthenticationProperties() {
|
public CrshShellAuthenticationProperties springAuthenticationProperties() {
|
||||||
return new SpringAuthenticationProperties();
|
return new SpringAuthenticationProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ public class CrshAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link FSDriver} to expose Spring {@link Resource}s to CRaSH.
|
* {@link FSDriver} to wrap Spring's {@link Resource} abstraction to CRaSH.
|
||||||
*/
|
*/
|
||||||
private static class SimpleFileSystemDriver extends AbstractFSDriver<ResourceHandle> {
|
private static class SimpleFileSystemDriver extends AbstractFSDriver<ResourceHandle> {
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ public class CrshAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ResourceHandle} for a file.
|
* {@link ResourceHandle} for a file backed by a Spring {@link Resource}.
|
||||||
*/
|
*/
|
||||||
private static class FileHandle extends ResourceHandle {
|
private static class FileHandle extends ResourceHandle {
|
||||||
|
|
||||||
|
|
|
@ -337,15 +337,13 @@ public class ShellProperties {
|
||||||
public static class SpringAuthenticationProperties extends
|
public static class SpringAuthenticationProperties extends
|
||||||
CrshShellAuthenticationProperties {
|
CrshShellAuthenticationProperties {
|
||||||
|
|
||||||
private String[] roles = new String[] { "ROLE_ADMIN" };
|
private String[] roles = new String[] { "ADMIN" };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyToCrshShellConfig(Properties config) {
|
protected void applyToCrshShellConfig(Properties config) {
|
||||||
if (this.roles != null) {
|
|
||||||
config.put("crash.auth.spring.roles",
|
config.put("crash.auth.spring.roles",
|
||||||
StringUtils.arrayToCommaDelimitedString(this.roles));
|
StringUtils.arrayToCommaDelimitedString(this.roles));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void setRoles(String[] roles) {
|
public void setRoles(String[] roles) {
|
||||||
// 'roles' can be empty. This means no special to access right to connect to
|
// 'roles' can be empty. This means no special to access right to connect to
|
||||||
|
|
|
@ -314,8 +314,8 @@ public class CrshAutoConfigurationTests {
|
||||||
authentication = new UsernamePasswordAuthenticationToken(
|
authentication = new UsernamePasswordAuthenticationToken(
|
||||||
authentication.getPrincipal(),
|
authentication.getPrincipal(),
|
||||||
authentication.getCredentials(),
|
authentication.getCredentials(),
|
||||||
Collections.singleton(new SimpleGrantedAuthority(
|
Collections
|
||||||
"ROLE_ADMIN")));
|
.singleton(new SimpleGrantedAuthority("ADMIN")));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new BadCredentialsException("Invalid username and password");
|
throw new BadCredentialsException("Invalid username and password");
|
||||||
|
@ -328,7 +328,9 @@ public class CrshAutoConfigurationTests {
|
||||||
@Bean
|
@Bean
|
||||||
public AccessDecisionManager accessDecisionManager() {
|
public AccessDecisionManager accessDecisionManager() {
|
||||||
List<AccessDecisionVoter> voters = new ArrayList<AccessDecisionVoter>();
|
List<AccessDecisionVoter> voters = new ArrayList<AccessDecisionVoter>();
|
||||||
voters.add(new RoleVoter());
|
RoleVoter voter = new RoleVoter();
|
||||||
|
voter.setRolePrefix("");
|
||||||
|
voters.add(voter);
|
||||||
AccessDecisionManager result = new UnanimousBased(voters);
|
AccessDecisionManager result = new UnanimousBased(voters);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue