-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* hot fix UI on user modification, add reff example from schema component, enhance path mock * enhance crud and add security configuration and enhance ui fixing some ui * enhance delete and validation * enhance delete and validation * update js * update js * enhance pattern * fixing package log
- Loading branch information
Showing
67 changed files
with
345 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...mockyup/controllers/AdviceController.java → ...yup/base/controller/AdviceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
...z/mockyup/controllers/BaseController.java → ...ckyup/base/controller/BaseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/main/java/com/github/dekaulitz/mockyup/controllers/ErrorHandlerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
src/main/java/com/github/dekaulitz/mockyup/controllers/MockControllers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/java/com/github/dekaulitz/mockyup/controllers/UiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 7 additions & 6 deletions
13
src/main/java/com/github/dekaulitz/mockyup/controllers/UserControllers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/github/dekaulitz/mockyup/domain/auth/base/AuthInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.github.dekaulitz.mockyup.domain.auth.base; | ||
|
||
import com.github.dekaulitz.mockyup.domain.auth.vmodels.DtoAuthProfileVmodel; | ||
import com.github.dekaulitz.mockyup.infrastructure.errors.handlers.UnathorizedAccess; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
|
||
public interface AuthInterface { | ||
DtoAuthProfileVmodel generateAccessToken(String username, String password) throws UnathorizedAccess, UnsupportedEncodingException; | ||
|
||
DtoAuthProfileVmodel refreshingToken(String token) throws UnathorizedAccess, UnsupportedEncodingException; | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/com/github/dekaulitz/mockyup/domain/auth/models/AuthModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.github.dekaulitz.mockyup.domain.auth.models; | ||
|
||
import com.github.dekaulitz.mockyup.domain.auth.base.AuthInterface; | ||
import com.github.dekaulitz.mockyup.domain.auth.vmodels.DtoAuthProfileVmodel; | ||
import com.github.dekaulitz.mockyup.infrastructure.db.entities.UserEntities; | ||
import com.github.dekaulitz.mockyup.infrastructure.db.repositories.UserRepository; | ||
import com.github.dekaulitz.mockyup.infrastructure.errors.handlers.UnathorizedAccess; | ||
import com.github.dekaulitz.mockyup.utils.Hash; | ||
import com.github.dekaulitz.mockyup.utils.JwtManager; | ||
import com.github.dekaulitz.mockyup.utils.ResponseCode; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.util.Optional; | ||
|
||
@Service | ||
public class AuthModel implements AuthInterface { | ||
@Autowired | ||
private final UserRepository userRepository; | ||
|
||
public AuthModel(UserRepository userRepository) { | ||
this.userRepository = userRepository; | ||
} | ||
|
||
@Override | ||
public DtoAuthProfileVmodel generateAccessToken(String username, String password) throws UnsupportedEncodingException { | ||
UserEntities userExist = this.userRepository.findFirstByUsername(username); | ||
if (userExist == null) { | ||
throw new UnathorizedAccess(ResponseCode.INVALID_USERNAME_OR_PASSWORD); | ||
} | ||
boolean isAuthenticated = Hash.verifyHash(password, userExist.getPassword()); | ||
if (!isAuthenticated) throw new UnathorizedAccess(ResponseCode.INVALID_USERNAME_OR_PASSWORD); | ||
return this.renderingAccessToken(userExist); | ||
} | ||
|
||
@Override | ||
public DtoAuthProfileVmodel refreshingToken(String token) throws UnsupportedEncodingException { | ||
Optional<String> userId = JwtManager.getUserIdFromToken(token); | ||
if (!userId.isPresent()) throw new UnathorizedAccess(ResponseCode.TOKEN_INVALID); | ||
Optional<UserEntities> userEntities = this.userRepository.findById(userId.get()); | ||
if (!userEntities.isPresent()) | ||
throw new UnathorizedAccess(ResponseCode.TOKEN_INVALID); | ||
return this.renderingAccessToken(userEntities.get()); | ||
} | ||
|
||
private DtoAuthProfileVmodel renderingAccessToken(UserEntities userEntities) throws UnsupportedEncodingException { | ||
DtoAuthProfileVmodel auth = new DtoAuthProfileVmodel(); | ||
auth.setId(userEntities.getId()); | ||
auth.setAccessMenus(userEntities.getAccessList()); | ||
auth.setUsername(userEntities.getUsername()); | ||
auth.setToken(JwtManager.generateToken(userEntities.getId(), userEntities.getUsername(), userEntities.getAccessList())); | ||
return auth; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/github/dekaulitz/mockyup/domain/auth/vmodels/DtoAuthProfileVmodel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.github.dekaulitz.mockyup.domain.auth.vmodels; | ||
|
||
import lombok.*; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@Setter | ||
|
||
public class DtoAuthProfileVmodel { | ||
private String id; | ||
private String username; | ||
private String token; | ||
private List<String> accessMenus; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/com/github/dekaulitz/mockyup/domain/mocks/base/MockInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.github.dekaulitz.mockyup.domain.mocks.base; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.github.dekaulitz.mockyup.domain.mocks.vmodels.DtoMockLookupVmodel; | ||
import com.github.dekaulitz.mockyup.domain.mocks.vmodels.DtoMockupDetailVmodel; | ||
import com.github.dekaulitz.mockyup.domain.mocks.vmodels.DtoMockupHistoryVmodel; | ||
import com.github.dekaulitz.mockyup.domain.mocks.vmodels.MockVmodel; | ||
import com.github.dekaulitz.mockyup.domain.users.vmodels.AddUserAccessVmodel; | ||
import com.github.dekaulitz.mockyup.infrastructure.configuration.security.AuthenticationProfileModel; | ||
import com.github.dekaulitz.mockyup.infrastructure.db.entities.MockEntities; | ||
import com.github.dekaulitz.mockyup.infrastructure.db.entities.MockHistoryEntities; | ||
import com.github.dekaulitz.mockyup.infrastructure.db.repositories.paging.MockEntitiesPage; | ||
import com.github.dekaulitz.mockyup.infrastructure.errors.handlers.InvalidMockException; | ||
import com.github.dekaulitz.mockyup.infrastructure.errors.handlers.NotFoundException; | ||
import com.github.dekaulitz.mockyup.utils.MockHelper; | ||
import org.springframework.data.domain.Pageable; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.io.UnsupportedEncodingException; | ||
import java.util.List; | ||
|
||
public interface MockInterface { | ||
List<MockEntities> all(); | ||
|
||
MockEntities getById(String id, AuthenticationProfileModel authenticationProfileModel) throws NotFoundException; | ||
|
||
MockEntities save(MockVmodel view, AuthenticationProfileModel authenticationProfileModel) throws InvalidMockException; | ||
|
||
MockEntities updateByID(String id, MockVmodel view, AuthenticationProfileModel authenticationProfileModel) throws NotFoundException, InvalidMockException; | ||
|
||
void deleteById(String id, AuthenticationProfileModel authenticationProfileModel) throws NotFoundException; | ||
|
||
MockEntitiesPage paging(Pageable pageable, String q, AuthenticationProfileModel authenticationProfileModel); | ||
|
||
List<MockHistoryEntities> getMockHistories(String id); | ||
|
||
MockEntities getUserMocks(String id); | ||
|
||
List<DtoMockLookupVmodel> getUsersListOfMocks(String mockId); | ||
|
||
List<DtoMockupDetailVmodel> getDetailMockUpIdByUserAccess(String id, AuthenticationProfileModel authenticationProfileModel); | ||
|
||
MockHelper getMockMocking(HttpServletRequest request, String path, String id, String body) throws NotFoundException, JsonProcessingException, UnsupportedEncodingException, InvalidMockException; | ||
|
||
Object addUserAccessOnMock(String id, AddUserAccessVmodel vmodel, AuthenticationProfileModel authenticationProfileModel) throws NotFoundException; | ||
|
||
Object removeAccessUserOnMock(String id, String userId, AuthenticationProfileModel authenticationProfileModel) throws NotFoundException; | ||
|
||
DtoMockupHistoryVmodel geMockHistoryId(String id, String historyId, AuthenticationProfileModel authenticationProfileModel) throws NotFoundException; | ||
} |
Oops, something went wrong.