Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
82fc2634
Commit
82fc2634
authored
Feb 14, 2017
by
zh9314
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'package' of github.com:skoulouzis/DRIP into package
Update for pushing.
parents
09b05117
7ca77afd
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
256 additions
and
132 deletions
+256
-132
MongoConfig.java
...i/src/main/java/nl/uva/sne/drip/api/conf/MongoConfig.java
+2
-18
MultipartConfig.java
...c/main/java/nl/uva/sne/drip/api/conf/MultipartConfig.java
+1
-1
SecurityConfig.java
...rc/main/java/nl/uva/sne/drip/api/conf/SecurityConfig.java
+15
-7
SpringSecurityInitializer.java
...a/nl/uva/sne/drip/api/conf/SpringSecurityInitializer.java
+4
-2
WebAppInitializer.java
...main/java/nl/uva/sne/drip/api/conf/WebAppInitializer.java
+2
-2
UserDao.java
drip-api/src/main/java/nl/uva/sne/drip/api/dao/UserDao.java
+2
-0
CloudConfigurationController.java
...l/uva/sne/drip/api/rest/CloudConfigurationController.java
+4
-4
PlannerController.java
...main/java/nl/uva/sne/drip/api/rest/PlannerController.java
+1
-1
ToscaController.java
...c/main/java/nl/uva/sne/drip/api/rest/ToscaController.java
+4
-4
UserController.java
...rc/main/java/nl/uva/sne/drip/api/rest/UserController.java
+9
-5
UserPublicKeysController.java
...va/nl/uva/sne/drip/api/rest/UserPublicKeysController.java
+5
-5
UserService.java
...rc/main/java/nl/uva/sne/drip/api/service/UserService.java
+81
-0
RESTTest.java
drip-api/src/test/java/nl/uva/sne/drip/rest/RESTTest.java
+1
-1
User.java
...ons/src/main/java/nl/uva/sne/drip/commons/types/User.java
+67
-38
UserRole.java
...src/main/java/nl/uva/sne/drip/commons/types/UserRole.java
+58
-0
PasswordUtil.java
...main/java/nl/uva/sne/drip/commons/utils/PasswordUtil.java
+0
-44
No files found.
drip-api/src/main/java/nl/uva/sne/drip/api/conf/MongoConfig.java
View file @
82fc2634
...
@@ -17,18 +17,12 @@ package nl.uva.sne.drip.api.conf;
...
@@ -17,18 +17,12 @@ package nl.uva.sne.drip.api.conf;
import
com.mongodb.Mongo
;
import
com.mongodb.Mongo
;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.
Be
an
;
import
org.springframework.context.annotation.
ComponentSc
an
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.context.annotation.PropertySources
;
import
org.springframework.context.annotation.PropertySources
;
import
org.springframework.data.mongodb.MongoDbFactory
;
import
org.springframework.data.mongodb.config.AbstractMongoConfiguration
;
import
org.springframework.data.mongodb.config.AbstractMongoConfiguration
;
import
org.springframework.data.mongodb.core.convert.DbRefResolver
;
import
org.springframework.data.mongodb.core.convert.DefaultDbRefResolver
;
import
org.springframework.data.mongodb.core.convert.MappingMongoConverter
;
import
org.springframework.data.mongodb.core.mapping.MongoMappingContext
;
import
org.springframework.data.mongodb.repository.config.EnableMongoRepositories
;
import
org.springframework.data.mongodb.repository.config.EnableMongoRepositories
;
/**
/**
...
@@ -41,6 +35,7 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie
...
@@ -41,6 +35,7 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie
@PropertySource
(
value
=
"classpath:drip.properties"
,
ignoreResourceNotFound
=
true
),
@PropertySource
(
value
=
"classpath:drip.properties"
,
ignoreResourceNotFound
=
true
),
@PropertySource
(
value
=
"file:etc/drip.properties"
,
ignoreResourceNotFound
=
true
)
@PropertySource
(
value
=
"file:etc/drip.properties"
,
ignoreResourceNotFound
=
true
)
})
})
@ComponentScan
(
"nl.uva.sne.drip"
)
public
class
MongoConfig
extends
AbstractMongoConfiguration
{
public
class
MongoConfig
extends
AbstractMongoConfiguration
{
@Value
(
"${db.name}"
)
@Value
(
"${db.name}"
)
...
@@ -54,7 +49,6 @@ public class MongoConfig extends AbstractMongoConfiguration {
...
@@ -54,7 +49,6 @@ public class MongoConfig extends AbstractMongoConfiguration {
// private MongoDbFactory mongoFactory;
// private MongoDbFactory mongoFactory;
// @Autowired
// @Autowired
// private MongoMappingContext mongoMappingContext;
// private MongoMappingContext mongoMappingContext;
@Override
@Override
protected
String
getDatabaseName
()
{
protected
String
getDatabaseName
()
{
return
dbName
;
return
dbName
;
...
@@ -69,14 +63,4 @@ public class MongoConfig extends AbstractMongoConfiguration {
...
@@ -69,14 +63,4 @@ public class MongoConfig extends AbstractMongoConfiguration {
protected
String
getMappingBasePackage
()
{
protected
String
getMappingBasePackage
()
{
return
"nl.uva.sne.drip"
;
return
"nl.uva.sne.drip"
;
}
}
// @Bean
// public MappingMongoConverter mongoConverter() throws Exception {
// DbRefResolver dbRefResolver = new DefaultDbRefResolver(mongoFactory);
// MappingMongoConverter mongoConverter = new MappingMongoConverter(dbRefResolver, mongoMappingContext);
// mongoConverter.setMapKeyDotReplacement('\uff0E');
// mongoConverter.afterPropertiesSet();
// return mongoConverter;
// }
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/conf/Config.java
→
drip-api/src/main/java/nl/uva/sne/drip/api/conf/
Multipart
Config.java
View file @
82fc2634
...
@@ -30,7 +30,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
...
@@ -30,7 +30,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
})
})
@EnableWebMvc
@EnableWebMvc
public
class
Config
{
public
class
Multipart
Config
{
@Bean
(
name
=
"multipartResolver"
)
@Bean
(
name
=
"multipartResolver"
)
public
CommonsMultipartResolver
createMultipartResolver
()
{
public
CommonsMultipartResolver
createMultipartResolver
()
{
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/conf/SecurityConfig.java
View file @
82fc2634
...
@@ -15,34 +15,42 @@
...
@@ -15,34 +15,42 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
conf
;
package
nl
.
uva
.
sne
.
drip
.
api
.
conf
;
import
nl.uva.sne.drip.api.service.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
nl.uva.sne.drip.api.dao.UserDao
;
/**
/**
*
*
* @author S. Koulouzis
*/
*/
@Configuration
@EnableWebSecurity
@EnableWebSecurity
@EnableGlobalMethodSecurity
(
jsr250Enabled
=
true
)
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Autowired
@Autowired
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
UserService
userService
;
// auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
auth
.
inMemoryAuthentication
()
@Autowired
.
withUser
(
"user"
).
password
(
"password"
).
roles
(
"USER"
);
public
void
configureGlobal
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
userDetailsService
(
userService
).
passwordEncoder
(
passwordEncoder
());
}
}
// @Override
// protected void configure(HttpSecurity http) throws Exception {
//// http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin();
// http.csrf().disable();
// }
@Bean
@Bean
public
PasswordEncoder
passwordEncoder
()
{
public
PasswordEncoder
passwordEncoder
()
{
PasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
PasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
return
encoder
;
return
encoder
;
}
}
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/conf/
MessageSecurityWebApplication
Initializer.java
→
drip-api/src/main/java/nl/uva/sne/drip/api/conf/
SpringSecurity
Initializer.java
View file @
82fc2634
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
conf
;
package
nl
.
uva
.
sne
.
drip
.
api
.
conf
;
public
class
MessageSecurityWebApplicationInitializer
{
import
org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer
;
//extends AbstractSecurityWebApplicationInitializer {
public
class
SpringSecurityInitializer
extends
AbstractSecurityWebApplicationInitializer
{
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/conf/WebAppInitializer.java
View file @
82fc2634
...
@@ -25,9 +25,9 @@ public class WebAppInitializer implements WebApplicationInitializer {
...
@@ -25,9 +25,9 @@ public class WebAppInitializer implements WebApplicationInitializer {
@Override
@Override
public
void
onStartup
(
ServletContext
servletContext
)
throws
ServletException
{
public
void
onStartup
(
ServletContext
servletContext
)
throws
ServletException
{
AnnotationConfigWebApplicationContext
ctx
=
new
AnnotationConfigWebApplicationContext
();
AnnotationConfigWebApplicationContext
ctx
=
new
AnnotationConfigWebApplicationContext
();
ctx
.
register
(
Config
.
class
);
ctx
.
register
(
Multipart
Config
.
class
);
ctx
.
register
(
MongoConfig
.
class
);
ctx
.
register
(
MongoConfig
.
class
);
//
ctx.register(SecurityConfig.class);
ctx
.
register
(
SecurityConfig
.
class
);
ctx
.
setServletContext
(
servletContext
);
ctx
.
setServletContext
(
servletContext
);
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/dao/UserDao.java
View file @
82fc2634
...
@@ -24,4 +24,6 @@ import org.springframework.data.mongodb.repository.MongoRepository;
...
@@ -24,4 +24,6 @@ import org.springframework.data.mongodb.repository.MongoRepository;
*/
*/
public
interface
UserDao
extends
MongoRepository
<
User
,
String
>
{
public
interface
UserDao
extends
MongoRepository
<
User
,
String
>
{
public
User
findByUsername
(
String
username
);
}
}
drip-api/src/main/java/nl/uva/sne/drip/api/rest/CloudConfigurationController.java
View file @
82fc2634
...
@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.PathVariable;
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
@RequestMapping
(
"/
rest/configuration
"
)
@RequestMapping
(
"/
configuration/cloud
"
)
@Component
@Component
public
class
CloudConfigurationController
{
public
class
CloudConfigurationController
{
...
@@ -40,7 +40,7 @@ public class CloudConfigurationController {
...
@@ -40,7 +40,7 @@ public class CloudConfigurationController {
private
CloudCredentialsDao
cloudCredentialsDao
;
private
CloudCredentialsDao
cloudCredentialsDao
;
// curl -H "Content-Type: application/json" -X POST -d '{"key":"my_secret_password","keyIdAlias":"geni","logineKys":[{"attributes":null,"key":"-----BEGINRSAPUBLICKEY-----\nMIIBCgKCAQEA+xGZ/wcz9ugFpP07Nspo6U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Go2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----ENDRSAPRIVATEKEY-----","type":"PRIVATE"}],"cloudProviderName":"exogeni"}' http://localhost:8080/drip-api/
rest/
configuration
// curl -H "Content-Type: application/json" -X POST -d '{"key":"my_secret_password","keyIdAlias":"geni","logineKys":[{"attributes":null,"key":"-----BEGINRSAPUBLICKEY-----\nMIIBCgKCAQEA+xGZ/wcz9ugFpP07Nspo6U17l0YhFiFpxxU4pTk3Lifz9R3zsIsu\nERwta7+fWIfxOo208ett/jhskiVodSEt3QBGh4XBipyWopKwZ93HHaDVZAALi/2A\n+xTBtWdEo7XGUujKDvC2/aZKukfjpOiUI8AhLAfjmlcD/UZ1QPh0mHsglRNCmpCw\nmwSXA9VNmhz+PiB+Dml4WWnKW/VHo2ujTXxq7+efMU4H2fny3Se3KYOsFPFGZ1TN\nQSYlFuShWrHPtiLmUdPoP6CV2mML1tk+l7DIIqXrQhLUKDACeM5roMx0kLhUWB8P\n+0uj1CNlNN4JRZlC7xFfqiMbFRU9Z4N6YwIDAQAB\n-----ENDRSAPUBLICKEY-----","type":"PUBLIC"},{"attributes":null,"key":"-----BEGINRSAPRIVATEKEY-----\nMIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp\nwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5\n1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh\n3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2\npIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX\nGukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il\nAkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF\nL0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k\nX6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----ENDRSAPRIVATEKEY-----","type":"PRIVATE"}],"cloudProviderName":"exogeni"}' http://localhost:8080/drip-api/configuration
// curl -H "Content-Type: application/json" -X POST -d '{"key":"AKISAKISAKIS","keyIdAlias":"6J76J76J76J76J76J76J7","logineKys":[{"attributes":{"domain_name":"California"},"type":"PUBLIC","key":"-----BEGINRSAPRIVATEKEY-----\nMIIEpQIBAAKCAQEA3Tz2mr7SZiAMfQyuvBjM9Oi..Z1BjP5CE/Wm/Rr500P\nRK+Lh9x5eJPo5CAZ3/ANBE0sTK0ZsDGMak2m1g7..3VHqIxFTz0Ta1d+NAj\nwnLe4nOb7/eEJbDPkk05ShhBrJGBKKxb8n104o/..PdzbFMIyNjJzBM2o5y\n5A13wiLitEO7nco2WfyYkQzaxCw0AwzlkVHiIyC..71pSzkv6sv+4IDMbT/\nXpCo8L6wTarzrywnQsh+etLD6FtTjYbbrvZ8RQM..Hg2qxraAV++HNBYmNW\ns0duEdjUbJK+ZarypXI9TtnS4o1Ckj7POfljiQI..I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mF5Kmj\nDtkpjGHQzPF6vOe907y5NQLvVFGXUq/FIJZxB8k..fJdHEm2M4=\n-----ENDRSAPRIVATEKEY-----"},{"attributes":{"domain_name":"Virginia"},"type":"PUBLIC","key":"-----BEGINRSAPRIVATEKEY-----\nMIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp\nwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5\n1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh\n3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2\npIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX\nGukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il\nAkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF\nL0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k\nX6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----ENDRSAPRIVATEKEY-----"}],"cloudProviderName":"ec2"}'
// curl -H "Content-Type: application/json" -X POST -d '{"key":"AKISAKISAKIS","keyIdAlias":"6J76J76J76J76J76J76J7","logineKys":[{"attributes":{"domain_name":"California"},"type":"PUBLIC","key":"-----BEGINRSAPRIVATEKEY-----\nMIIEpQIBAAKCAQEA3Tz2mr7SZiAMfQyuvBjM9Oi..Z1BjP5CE/Wm/Rr500P\nRK+Lh9x5eJPo5CAZ3/ANBE0sTK0ZsDGMak2m1g7..3VHqIxFTz0Ta1d+NAj\nwnLe4nOb7/eEJbDPkk05ShhBrJGBKKxb8n104o/..PdzbFMIyNjJzBM2o5y\n5A13wiLitEO7nco2WfyYkQzaxCw0AwzlkVHiIyC..71pSzkv6sv+4IDMbT/\nXpCo8L6wTarzrywnQsh+etLD6FtTjYbbrvZ8RQM..Hg2qxraAV++HNBYmNW\ns0duEdjUbJK+ZarypXI9TtnS4o1Ckj7POfljiQI..IBAFyidxtqRQyv5KrD\nkbJ+q+rsJxQlaipn2M4lGuQJEfIxELFDyd3XpxP..Un/82NZNXlPmRIopXs\n2T91jiLZEUKQw+n73j26adTbteuEaPGSrTZxBLR..yssO0wWomUyILqVeti\n6AkL0NJAuKcucHGqWVgUIa4g1haE0ilcm6dWUDo..fd+PpzdCJf1s4NdUWK\nYV2GJcutGQb+jqT5DTUqAgST7N8M28rwjK6nVMI..BUpP0xpPnuYDyPOw6x\n4hBt8DZQYyduzIXBXRBKNiNdv8fum68/5klHxp6..4HRkMUL958UVeljUsT\nBFQlO9UCgYEA/VqzXVzlz8K36VSTMPEhB5zBATV..PRiXtYK1YpYV4/jSUj\nvvT4hP8uoYNC+BlEMi98LtnxZIh0V4rqHDsScAq..VyeSLH0loKMZgpwFEm\nbEIDnEOD0nKrfT/9K9sPYgvB43wsLEtUujaYw3W..Liy0WKmB8CgYEA34xn\n1QlOOhHBn9Z8qYjoDYhvcj+a89tD9eMPhesfQFw..rsfGcXIonFmWdVygbe\n6Doihc+GIYIq/QP4jgMksE1ADvczJSke92ZfE2i..fitBpQERNJO0BlabfP\nALs5NssKNmLkWS2U2BHCbv4DzDXwiQB37KPOL1c..kBHfF2/htIs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C9m66KrheO9HPTJuo3/9s5p+sqGxOlF\nL0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k\nX6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl\nU9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ\n37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0=\n-----ENDRSAPRIVATEKEY-----"}],"cloudProviderName":"ec2"}'
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
@ResponseBody
public
@ResponseBody
...
@@ -49,12 +49,12 @@ public class CloudConfigurationController {
...
@@ -49,12 +49,12 @@ public class CloudConfigurationController {
return
cc
.
getId
();
return
cc
.
getId
();
}
}
@RequestMapping
(
value
=
"/
cloud/
{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
public
CloudCredentials
get
(
@PathVariable
(
"id"
)
String
id
)
{
public
CloudCredentials
get
(
@PathVariable
(
"id"
)
String
id
)
{
return
cloudCredentialsDao
.
findOne
(
id
);
return
cloudCredentialsDao
.
findOne
(
id
);
}
}
@RequestMapping
(
value
=
"/
cloud/
ids"
)
@RequestMapping
(
value
=
"/ids"
)
public
@ResponseBody
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
String
>
getIds
()
{
List
<
CloudCredentials
>
all
=
cloudCredentialsDao
.
findAll
();
List
<
CloudCredentials
>
all
=
cloudCredentialsDao
.
findAll
();
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/PlannerController.java
View file @
82fc2634
...
@@ -49,7 +49,7 @@ import nl.uva.sne.drip.api.dao.ToscaDao;
...
@@ -49,7 +49,7 @@ import nl.uva.sne.drip.api.dao.ToscaDao;
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
@RequestMapping
(
"/
rest/
planner"
)
@RequestMapping
(
"/planner"
)
@Component
@Component
public
class
PlannerController
{
public
class
PlannerController
{
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/ToscaController.java
View file @
82fc2634
...
@@ -42,7 +42,7 @@ import nl.uva.sne.drip.api.dao.ToscaDao;
...
@@ -42,7 +42,7 @@ import nl.uva.sne.drip.api.dao.ToscaDao;
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
@RequestMapping
(
"/
rest/
tosca"
)
@RequestMapping
(
"/tosca"
)
@Component
@Component
public
class
ToscaController
{
public
class
ToscaController
{
...
@@ -51,7 +51,7 @@ public class ToscaController {
...
@@ -51,7 +51,7 @@ public class ToscaController {
@Autowired
@Autowired
private
ToscaDao
dao
;
private
ToscaDao
dao
;
// curl -X POST -F "file=@DRIP/input.yaml" localhost:8080/drip-api/
rest/
upload
// curl -X POST -F "file=@DRIP/input.yaml" localhost:8080/drip-api/upload
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
public
@ResponseBody
String
toscaUpload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
String
toscaUpload
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
...
@@ -87,7 +87,7 @@ public class ToscaController {
...
@@ -87,7 +87,7 @@ public class ToscaController {
return
null
;
return
null
;
}
}
// curl http://localhost:8080/drip-api/
rest/
tosca/589e1160d9925f9dc127e882/?fromat=yaml
// curl http://localhost:8080/drip-api/tosca/589e1160d9925f9dc127e882/?fromat=yaml
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
,
params
=
{
"fromat"
})
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
,
params
=
{
"fromat"
})
public
@ResponseBody
public
@ResponseBody
String
get
(
@PathVariable
(
"id"
)
String
id
,
@RequestParam
(
value
=
"fromat"
)
String
fromat
)
{
String
get
(
@PathVariable
(
"id"
)
String
id
,
@RequestParam
(
value
=
"fromat"
)
String
fromat
)
{
...
@@ -112,7 +112,7 @@ public class ToscaController {
...
@@ -112,7 +112,7 @@ public class ToscaController {
return
null
;
return
null
;
}
}
// http://localhost:8080/drip-api/
rest/
tosca/ids
// http://localhost:8080/drip-api/tosca/ids
@RequestMapping
(
value
=
"/ids"
)
@RequestMapping
(
value
=
"/ids"
)
public
@ResponseBody
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
String
>
getIds
()
{
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/UserController.java
View file @
82fc2634
...
@@ -17,6 +17,7 @@ package nl.uva.sne.drip.api.rest;
...
@@ -17,6 +17,7 @@ package nl.uva.sne.drip.api.rest;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
import
javax.annotation.security.RolesAllowed
;
import
nl.uva.sne.drip.commons.types.User
;
import
nl.uva.sne.drip.commons.types.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -25,32 +26,35 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -25,32 +26,35 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
nl.uva.sne.drip.api.
dao.UserDao
;
import
nl.uva.sne.drip.api.
service.UserService
;
/**
/**
*
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
//@CrossOrigin(origins = "http://domain2.com", maxAge = 3600)
@RestController
@RestController
@RequestMapping
(
"/user/"
)
@RequestMapping
(
"/user/"
)
@Component
@Component
public
class
UserController
{
public
class
UserController
{
@Autowired
@Autowired
private
User
Dao
userRepository
;
private
User
Service
service
;
@RequestMapping
(
value
=
"/register"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/register"
,
method
=
RequestMethod
.
POST
)
@RolesAllowed
({
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
String
register
(
User
user
)
{
String
register
(
User
user
)
{
userRepository
.
save
(
user
);
service
.
getDao
()
.
save
(
user
);
return
"registration"
;
return
user
.
getId
()
;
}
}
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RolesAllowed
({
UserService
.
ADMIN
})
public
@ResponseBody
public
@ResponseBody
User
get
(
@PathVariable
(
"id"
)
String
id
)
{
User
get
(
@PathVariable
(
"id"
)
String
id
)
{
try
{
try
{
return
userRepository
.
findOne
(
id
);
return
service
.
getDao
()
.
findOne
(
id
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
UserController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Logger
.
getLogger
(
UserController
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/rest/UserPublicKeysController.java
View file @
82fc2634
...
@@ -38,14 +38,14 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -38,14 +38,14 @@ import org.springframework.web.bind.annotation.PathVariable;
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@RestController
@RestController
@RequestMapping
(
"/
rest/
user_key"
)
@RequestMapping
(
"/user_key"
)
@Component
@Component
public
class
UserPublicKeysController
{
public
class
UserPublicKeysController
{
@Autowired
@Autowired
private
UserKeyDao
dao
;
private
UserKeyDao
dao
;
// curl -v -X POST -F "file=@.ssh/id_dsa.pub" localhost:8080/drip-api/
rest/
user_key/upload
// curl -v -X POST -F "file=@.ssh/id_dsa.pub" localhost:8080/drip-api/user_key/upload
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/upload"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
public
@ResponseBody
String
uploadUserPublicKeys
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
String
uploadUserPublicKeys
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
...
@@ -70,7 +70,7 @@ public class UserPublicKeysController {
...
@@ -70,7 +70,7 @@ public class UserPublicKeysController {
}
}
// curl -H "Content-Type: application/json" -X POST -d '{"key":"ssh-rsa AAAAB3NzaDWBqs75i849MytgwgQcRYMcsXIki0yeYTKABH6JqoiyFBHtYlyh/EV1t6cujb9LyNP4J5EN4fPbtwKYvxecd0LojSPxl4wjQlfrHyg6iKUYB7hVzGqACMvgYZHrtHPfrdEmOGPplPVPpoaX2j+u0BZ0yYhrWMKjzyYZKa68yy5N18+Gq+1p83HfUDwIU9wWaUYdgEvDujqF6b8p3z6LDx9Ob+RanSMZSt+b8eZRcd+F2Oy/gieJEJ8kc152VIOv8UY1xB3hVEwVnSRGgrAsa+9PChfF6efXUGWiKf8KBlWgBOYsSTsOY4ks9zkXMnbcTdC+o7xspOkyIcWjv us@u\n","name":"id_rsa.pub"}' localhost:8080/drip-api/
rest/
user_key/
// curl -H "Content-Type: application/json" -X POST -d '{"key":"ssh-rsa AAAAB3NzaDWBqs75i849MytgwgQcRYMcsXIki0yeYTKABH6JqoiyFBHtYlyh/EV1t6cujb9LyNP4J5EN4fPbtwKYvxecd0LojSPxl4wjQlfrHyg6iKUYB7hVzGqACMvgYZHrtHPfrdEmOGPplPVPpoaX2j+u0BZ0yYhrWMKjzyYZKa68yy5N18+Gq+1p83HfUDwIU9wWaUYdgEvDujqF6b8p3z6LDx9Ob+RanSMZSt+b8eZRcd+F2Oy/gieJEJ8kc152VIOv8UY1xB3hVEwVnSRGgrAsa+9PChfF6efXUGWiKf8KBlWgBOYsSTsOY4ks9zkXMnbcTdC+o7xspOkyIcWjv us@u\n","name":"id_rsa.pub"}' localhost:8080/drip-api/user_key/
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
@ResponseBody
public
@ResponseBody
String
postConf
(
UserPublicKey
uk
)
throws
JSONException
{
String
postConf
(
UserPublicKey
uk
)
throws
JSONException
{
...
@@ -80,13 +80,13 @@ public class UserPublicKeysController {
...
@@ -80,13 +80,13 @@ public class UserPublicKeysController {
return
uk
.
getId
();
return
uk
.
getId
();
}
}
//curl localhost:8080/drip-api/
rest/
user_key/58a20be263d4a5898835676e
//curl localhost:8080/drip-api/user_key/58a20be263d4a5898835676e
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
public
UserPublicKey
get
(
@PathVariable
(
"id"
)
String
id
)
{
public
UserPublicKey
get
(
@PathVariable
(
"id"
)
String
id
)
{
return
dao
.
findOne
(
id
);
return
dao
.
findOne
(
id
);
}
}
// localhost:8080/drip-api/
rest/
user_key/ids
// localhost:8080/drip-api/user_key/ids
@RequestMapping
(
value
=
"/ids"
)
@RequestMapping
(
value
=
"/ids"
)
public
@ResponseBody
public
@ResponseBody
List
<
String
>
getIds
()
{
List
<
String
>
getIds
()
{
...
...
drip-api/src/main/java/nl/uva/sne/drip/api/service/UserService.java
0 → 100644
View file @
82fc2634
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
service
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
import
nl.uva.sne.drip.api.dao.UserDao
;
import
nl.uva.sne.drip.commons.types.User
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
/**
*
* @author S. Koulouzis
*/
@Service
public
class
UserService
implements
UserDetailsService
{
public
static
final
String
ADMIN
=
"ADMIN"
;
@Autowired
UserDao
dao
;
@Override
public
UserDetails
loadUserByUsername
(
String
username
)
throws
UsernameNotFoundException
{
try
{
// dao.deleteAll();
// User u = new User();
// u.setAccountNonExpired(true);
// u.setAccountNonLocked(true);
// Collection<GrantedAuthority> athorities = new HashSet<>();
// GrantedAuthority ga = new SimpleGrantedAuthority("ROLE_USER");
// athorities.add(ga);
// u.setAthorities(athorities);
// u.setCredentialsNonExpired(true);
// u.setEnabled(true);
// u.setPassword(new BCryptPasswordEncoder().encode("123"));
// u.setUsername(username);
// dao.save(u);
//
// User u2 = new User();
// u2.setAccountNonExpired(true);
// u2.setAccountNonLocked(true);
// athorities = new HashSet<>();
// ga = new SimpleGrantedAuthority("ROLE_ADMIN");
// athorities.add(ga);
// u2.setAthorities(athorities);
// u2.setCredentialsNonExpired(true);
// u2.setEnabled(true);
// u2.setPassword(new BCryptPasswordEncoder().encode("admin"));
// u2.setUsername("admin");
// dao.save(u2);
User
user
=
dao
.
findByUsername
(
username
);
return
user
;
}
catch
(
Exception
ex
)
{
Logger
.
getLogger
(
UserService
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
return
null
;
}
public
UserDao
getDao
()
{
return
dao
;
}
}
drip-api/src/test/java/nl/uva/sne/drip/rest/RESTTest.java
View file @
82fc2634
...
@@ -49,7 +49,7 @@ public class RESTTest {
...
@@ -49,7 +49,7 @@ public class RESTTest {
@BeforeClass
@BeforeClass
public
static
void
setUpClass
()
throws
URISyntaxException
{
public
static
void
setUpClass
()
throws
URISyntaxException
{
url
=
new
URI
(
"http://localhost:8080/drip-api/
rest/
upload"
);
url
=
new
URI
(
"http://localhost:8080/drip-api/upload"
);
toscaFile
=
new
File
(
"./etc/input.yaml"
);
toscaFile
=
new
File
(
"./etc/input.yaml"
);
}
}
...
...
drip-commons/src/main/java/nl/uva/sne/drip/commons/types/User.java
View file @
82fc2634
...
@@ -15,11 +15,8 @@
...
@@ -15,11 +15,8 @@
*/
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
types
;
package
nl
.
uva
.
sne
.
drip
.
commons
.
types
;
import
nl.uva.sne.drip.commons.utils.PasswordUtil
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.GrantedAuthority
;
...
@@ -32,52 +29,39 @@ import org.springframework.security.core.userdetails.UserDetails;
...
@@ -32,52 +29,39 @@ import org.springframework.security.core.userdetails.UserDetails;
@JsonIgnoreProperties
({
"password"
})
@JsonIgnoreProperties
({
"password"
})
@Document
@Document
public
class
User
implements
UserDetails
{
public
class
User
implements
UserDetails
{
@Id
@Id
private
String
id
;
private
String
id
;
private
Collection
<?
extends
GrantedAuthority
>
athorities
;
private
String
username
;
@JsonIgnore
private
String
password
;
private
String
password
;
private
String
username
;
private
List
<
String
>
roles
;
private
boolean
accountNonExpired
;
private
boolean
expired
;
private
boolean
accountNonLocked
;
private
boolean
nonLocked
;
private
boolean
credentialsNonExpired
;
private
boolean
credentialsNonExpired
;
private
boolean
enabled
;
private
boolean
enabled
;
private
Collection
<?
extends
GrantedAuthority
>
authorities
;
public
void
setPassword
(
String
password
)
throws
Exception
{
this
.
password
=
PasswordUtil
.
hash
(
password
);
}
public
boolean
isValide
(
String
password
)
throws
Exception
{
if
(
this
.
password
!=
null
&&
password
!=
null
)
{
return
PasswordUtil
.
validate
(
this
.
password
,
password
);
}
return
false
;
}
public
List
<
String
>
getRoles
()
{
return
roles
;
}
public
void
setRoles
(
List
<
String
>
roles
)
{
this
.
roles
=
roles
;
}
/**
* @return the id
*/
public
String
getId
()
{
public
String
getId
()
{
return
id
;
return
id
;
}
}
/**
* @param id the id to set
*/
public
void
setId
(
String
id
)
{
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
@Override
@Override
public
Collection
<?
extends
GrantedAuthority
>
getAuthorities
()
{
public
Collection
<?
extends
GrantedAuthority
>
getAuthorities
()
{
return
this
.
authorities
;
return
this
.
athorities
;
}
@Override
public
String
getPassword
()
{
return
this
.
password
;
}
}
@Override
@Override
...
@@ -87,12 +71,12 @@ public class User implements UserDetails {
...
@@ -87,12 +71,12 @@ public class User implements UserDetails {
@Override
@Override
public
boolean
isAccountNonExpired
()
{
public
boolean
isAccountNonExpired
()
{
return
this
.
e
xpired
;
return
this
.
accountNonE
xpired
;
}
}
@Override
@Override
public
boolean
isAccountNonLocked
()
{
public
boolean
isAccountNonLocked
()
{
return
this
.
n
onLocked
;
return
this
.
accountN
onLocked
;
}
}
@Override
@Override
...
@@ -105,8 +89,53 @@ public class User implements UserDetails {
...
@@ -105,8 +89,53 @@ public class User implements UserDetails {
return
this
.
enabled
;
return
this
.
enabled
;
}
}
@Override
/**
public
String
getPassword
()
{
* @param athorities the athorities to set
return
this
.
password
;
*/
public
void
setAthorities
(
Collection
<?
extends
GrantedAuthority
>
athorities
)
{
this
.
athorities
=
athorities
;
}
}
/**
* @param password the password to set
*/
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
/**
* @param username the username to set
*/
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
/**
* @param accountNonExpired the accountNonExpired to set
*/
public
void
setAccountNonExpired
(
boolean
accountNonExpired
)
{
this
.
accountNonExpired
=
accountNonExpired
;
}
/**
* @param accountNonLocked the accountNonLocked to set
*/
public
void
setAccountNonLocked
(
boolean
accountNonLocked
)
{
this
.
accountNonLocked
=
accountNonLocked
;
}
/**
* @param credentialsNonExpired the credentialsNonExpired to set
*/
public
void
setCredentialsNonExpired
(
boolean
credentialsNonExpired
)
{
this
.
credentialsNonExpired
=
credentialsNonExpired
;
}
/**
* @param enabled the enabled to set
*/
public
void
setEnabled
(
boolean
enabled
)
{
this
.
enabled
=
enabled
;
}
}
}
drip-
api/src/main/java/nl/uva/sne/drip/api/rest/UserServic
e.java
→
drip-
commons/src/main/java/nl/uva/sne/drip/commons/types/UserRol
e.java
View file @
82fc2634
...
@@ -13,30 +13,46 @@
...
@@ -13,30 +13,46 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
nl
.
uva
.
sne
.
drip
.
api
.
rest
;
package
nl
.
uva
.
sne
.
drip
.
commons
.
types
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
nl.uva.sne.drip.api.dao.UserDao
;
/**
/**
*
*
* @author S. Koulouzis
* @author S. Koulouzis
*/
*/
@
Service
@
Document
public
class
User
Service
implements
UserDetailsServic
e
{
public
class
User
Rol
e
{
@Autowired
private
Integer
userRoleId
;
private
UserDao
userRepository
;
private
String
role
;
@Override
/**
public
UserDetails
loadUserByUsername
(
String
string
)
throws
UsernameNotFoundException
{
* @return the userRoleId
*/
public
Integer
getUserRoleId
()
{
return
null
;
return
userRoleId
;
}
/**
* @param userRoleId the userRoleId to set
*/
public
void
setUserRoleId
(
Integer
userRoleId
)
{
this
.
userRoleId
=
userRoleId
;
}
/**
* @return the role
*/
public
String
getRole
()
{
return
role
;
}
/**
* @param role the role to set
*/
public
void
setRole
(
String
role
)
{
this
.
role
=
role
;
}
}
}
}
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/PasswordUtil.java
deleted
100644 → 0
View file @
09b05117
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
utils
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
/**
*
* @author S. Koulouzis
*/
public
class
PasswordUtil
{
public
static
String
hash
(
String
password
)
throws
NoSuchAlgorithmException
{
MessageDigest
messageDigest
=
MessageDigest
.
getInstance
(
"SHA-256"
);
messageDigest
.
update
(
password
.
getBytes
());
return
new
String
(
messageDigest
.
digest
());
}
public
static
boolean
validate
(
String
password
,
String
password0
)
throws
NoSuchAlgorithmException
{
MessageDigest
messageDigest
=
MessageDigest
.
getInstance
(
"SHA-256"
);
messageDigest
.
update
(
password
.
getBytes
());
String
h1
=
new
String
(
messageDigest
.
digest
());
messageDigest
.
update
(
password0
.
getBytes
());
String
h2
=
new
String
(
messageDigest
.
digest
());
return
h1
.
equals
(
h2
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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