Skip to content

Commit

Permalink
Update JWT tests, add encryption tests, refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazjara committed Feb 9, 2017
1 parent 6d63be4 commit 2a3feb4
Show file tree
Hide file tree
Showing 81 changed files with 1,780 additions and 1,685 deletions.
4 changes: 2 additions & 2 deletions modules/core/src/main/java/io/smsc/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Application {

public static void main(String[] args) {
// Solution of JCE problem for JDK 9 (reflection is not more needed)
Security.setProperty("crypto.policy", "unlimited");
SpringApplication.run(Application.class, args);
Security.setProperty("crypto.policy", "unlimited");
SpringApplication.run(Application.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* This class is extending base {@link Oracle10gDialect} class to
* register a double data type as float column type.
*
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
*/
public class Oracle10gDialectExtended extends Oracle10gDialect {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
* The RepositoryIdExposingConfiguration class is used for providing ID value exposing
* as a normal property for all entity classes.
*
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
*/
@Configuration
public class RepositoryIdExposingConfiguration extends RepositoryRestConfigurerAdapter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* The SpringDataRestValidationConfiguration class is used for customization
* hibernate bean validation to launch before entity is created or updated
*
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
*/
@Configuration
public class SpringDataRestValidationConfiguration extends RepositoryRestConfigurerAdapter {
Expand Down
29 changes: 14 additions & 15 deletions modules/core/src/main/java/io/smsc/controller/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* The AuthController class is used for mapping HTTP requests for receiving and updating
* access and refresh tokens onto specific methods
*
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
*/
@RestController
public class AuthController {
Expand All @@ -42,11 +42,11 @@ public AuthController(JWTTokenGenerationService jwtTokenGenerationService, JWTUs
* Method to receive {@link ResponseEntity} with {@link JWTAuthenticationResponse}
* which contains access and refresh tokens.
*
* @param request the {@link JWTAuthenticationRequest} to take credentials from
* @param response the {@link HttpServletResponse} to provide HTTP-specific
* functionality in sending a response
* @return the {@link JWTAuthenticationResponse} with valid access and
* refresh tokens
* @param request the {@link JWTAuthenticationRequest} to take credentials from
* @param response the {@link HttpServletResponse} to provide HTTP-specific
* functionality in sending a response
* @return the {@link JWTAuthenticationResponse} with valid access and
* refresh tokens
* @throws IOException on input error
*/
@PostMapping(path = "/rest/auth/token", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
Expand All @@ -60,19 +60,19 @@ public ResponseEntity<JWTAuthenticationResponse> token(@RequestBody JWTAuthentic
} catch (Exception ex) {
// going to send error
}
response.sendError(HttpServletResponse.SC_UNAUTHORIZED,"Credentials are invalid. Please enter valid username and password");
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Credentials are invalid. Please enter valid username and password");
return null;
}

/**
* Method to receive {@link ResponseEntity} with {@link JWTRefreshTokenResponse}
* which contains refreshed access token.
*
* @param request the {@link JWTRefreshTokenRequest} to take valid refresh
* token and expired access token from
* @param response the {@link HttpServletResponse} to provide HTTP-specific
* functionality in sending a response
* @return the {@link JWTRefreshTokenResponse} with refreshed access token
* @param request the {@link JWTRefreshTokenRequest} to take valid refresh
* token and expired access token from
* @param response the {@link HttpServletResponse} to provide HTTP-specific
* functionality in sending a response
* @return the {@link JWTRefreshTokenResponse} with refreshed access token
* @throws IOException on input error
*/
@PutMapping(path = "/rest/auth/token", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
Expand All @@ -85,8 +85,7 @@ public ResponseEntity<JWTRefreshTokenResponse> token(@RequestBody JWTRefreshToke
JWTRefreshTokenResponse token = new JWTRefreshTokenResponse(jwtTokenGenerationService.refreshToken(expiredAccessToken));
return new ResponseEntity<>(token, HttpStatus.OK);
}
}
catch (Exception ex) {
} catch (Exception ex) {
// going to send error
}
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Refresh or expired access token is invalid. Please enter valid tokens");
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/main/java/io/smsc/model/BaseEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* is applied to the entities that inherit from it. It contains only id property
* and equals/hashcode implementations.
*
* @author Nazar Lipkovskyy
* @see MappedSuperclass
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see MappedSuperclass
* @since 0.0.1-SNAPSHOT
*/
@MappedSuperclass
@Access(AccessType.FIELD)
Expand All @@ -28,7 +28,7 @@ public class BaseEntity implements Serializable {
@LastModifiedDate
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "LAST_MODIFIED_DATE", nullable = false)
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone="UTC")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC")
protected Date lastModifiedDate = new Date();

@Version
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/java/io/smsc/model/CustomerUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
/**
* Specifies CustomerUser class as an entity class.
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "CUSTOMER_USER_ACCOUNT", uniqueConstraints = {@UniqueConstraint(columnNames = {"USERNAME"}, name = "users_username_idx")})
Expand All @@ -43,7 +43,7 @@ public class CustomerUser extends BaseEntity {
@JsonIgnore
private String password;

@Column(name="SALT")
@Column(name = "SALT")
@JsonIgnore
private String salt;

Expand All @@ -64,14 +64,14 @@ public class CustomerUser extends BaseEntity {
private Boolean active = true;

@Column(name = "CREATED", nullable = false, updatable = false)
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone="UTC")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC")
private Date created = new Date();

@Column(name = "BLOCKED", nullable = false)
private Boolean blocked = false;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="CUSTOMER_ID", nullable = false)
@JoinColumn(name = "CUSTOMER_ID", nullable = false)
@JsonBackReference
private Customer customer;

Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/main/java/io/smsc/model/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
/**
* Specifies Role class as an entity class.
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "ROLE", uniqueConstraints = {@UniqueConstraint(columnNames = "NAME", name = "roles_unique_name_idx")})
public class Role extends BaseEntity{
public class Role extends BaseEntity {

@Id
@SequenceGenerator(name = "role_seq", sequenceName = "role_seq")
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/main/java/io/smsc/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
/**
* Specifies User class as an entity class.
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "USER_ACCOUNT", uniqueConstraints = {@UniqueConstraint(columnNames = {"USERNAME"}, name = "users_username_idx")})
Expand All @@ -47,7 +47,7 @@ public class User extends BaseEntity {
@JsonIgnore
private String password;

@Column(name="SALT")
@Column(name = "SALT")
@JsonIgnore
private String salt;

Expand All @@ -67,8 +67,8 @@ public class User extends BaseEntity {
@Column(name = "ACTIVE", nullable = false)
private Boolean active = true;

@Column(name = "CREATED",nullable = false, updatable = false)
@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone="UTC")
@Column(name = "CREATED", nullable = false, updatable = false)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "UTC")
private Date created = new Date();

@Column(name = "BLOCKED", nullable = false)
Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/main/java/io/smsc/model/acl/AclClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* Stores the fully qualified name of domain objects. It is made up of the package
* name and class name of the object.
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "ACL_CLASS", uniqueConstraints = {@UniqueConstraint(columnNames = "CLASS", name = "acl_class_idx")})
Expand Down
8 changes: 4 additions & 4 deletions modules/core/src/main/java/io/smsc/model/acl/AclEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
/**
* Stores the actual permissions assigned for each user and domain object.
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "ACL_ENTRY", uniqueConstraints = {@UniqueConstraint(columnNames = {"ACL_OBJECT_IDENTITY", "ACE_ORDER"}, name = "acl_identity_order_idx")})
Expand Down Expand Up @@ -48,7 +48,7 @@ public class AclEntry extends BaseEntity {
private Boolean granting;

/**
* A flag to indicate whether to audit a successful permission.
* A flag to indicate whether to audit a successful permission.
*/
@Column(name = "AUDIT_SUCCESS", nullable = false)
@NotNull(message = "{acl.entry.audit.success.validation}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
* Stores the actual identities of the domain objects. The identities are referenced via a
* unique id which is retrieved from other model tables.
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "ACL_OBJECT_IDENTITY", uniqueConstraints = {@UniqueConstraint(columnNames = {"OBJECT_ID_CLASS", "OBJECT_ID_IDENTITY"}, name = "acl_class_identity_idx")})
Expand All @@ -39,7 +39,7 @@ public class AclObjectIdentity extends BaseEntity {
* Refers to the id of the parent object if existing.
*/
@ManyToOne
@JoinColumn(name="PARENT_OBJECT")
@JoinColumn(name = "PARENT_OBJECT")
private AclObjectIdentity parentObject;

/**
Expand All @@ -51,8 +51,8 @@ public class AclObjectIdentity extends BaseEntity {
private AclSid ownerSid;

/**
* Refers to the id field in the acl_class. This is a reference to the fully qualified
* name of the class.
* Refers to the id field in the acl_class. This is a reference to the fully qualified
* name of the class.
*/
@ManyToOne
@JoinColumn(name = "OBJECT_ID_CLASS", nullable = false, unique = true)
Expand Down
6 changes: 3 additions & 3 deletions modules/core/src/main/java/io/smsc/model/acl/AclSid.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* Stores the name of the users which can be a principal (like usernames john, james, mark)
* or an authority (like roles ROLE_ADMIN, ROLE USER, ROLE_ANYONE).
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "ACL_SID", uniqueConstraints = {@UniqueConstraint(columnNames = {"SID", "PRINCIPAL"}, name = "acl_sid_principal_idx")})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
/**
* Specifies CustomerContact class as an entity class.
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @see Customer
* @see Type
* @see Salutation
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @see Customer
* @see Type
* @see Salutation
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "CUSTOMER_CONTACT", uniqueConstraints = {@UniqueConstraint(columnNames = "EMAIL_ADDRESS", name = "customer_contact_unique_email_address_idx")})
Expand Down Expand Up @@ -57,7 +57,7 @@ public class CustomerContact extends BaseEntity {
private String emailAddress;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="CUSTOMER_ID", nullable = false)
@JoinColumn(name = "CUSTOMER_ID", nullable = false)
@JsonBackReference
private Customer customer;

Expand All @@ -75,8 +75,8 @@ public CustomerContact() {
}

public CustomerContact(CustomerContact customerContact) {
this(customerContact.getId(),customerContact.getFirstname(),customerContact.getSurname(),customerContact.getPhone(),
customerContact.getMobilePhone(),customerContact.getFax(),customerContact.getEmailAddress(),customerContact.getType(),
this(customerContact.getId(), customerContact.getFirstname(), customerContact.getSurname(), customerContact.getPhone(),
customerContact.getMobilePhone(), customerContact.getFax(), customerContact.getEmailAddress(), customerContact.getType(),
customerContact.getSalutation(), customerContact.getCustomer());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* Specifies Salutations which can be used in {@link CustomerContact}
*
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
*/
public enum Salutation {
MR,
Expand Down
4 changes: 2 additions & 2 deletions modules/core/src/main/java/io/smsc/model/customer/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* Specifies Types which can be used in {@link CustomerContact}
*
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @since 0.0.1-SNAPSHOT
*/
public enum Type {
CEO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
/**
* Specifies Dashboard class as an entity class.
*
* @author Nazar Lipkovskyy
* @see BaseEntity
* @see User
* @since 0.0.1-SNAPSHOT
* @author Nazar Lipkovskyy
* @see BaseEntity
* @see User
* @since 0.0.1-SNAPSHOT
*/
@Entity
@Table(name = "DASHBOARD", uniqueConstraints = {@UniqueConstraint(columnNames = {"NAME"}, name = "dashboards_unique_name_user_idx")})
Expand All @@ -41,7 +41,7 @@ public class Dashboard extends BaseEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JsonBackReference
@JoinColumn(name="USER_ACCOUNT_ID", nullable = false)
@JoinColumn(name = "USER_ACCOUNT_ID", nullable = false)
private User user;

@OneToMany(
Expand Down
Loading

0 comments on commit 2a3feb4

Please sign in to comment.