Skip to content

Commit

Permalink
Merge pull request #190 from /issues/189-code-cleanup
Browse files Browse the repository at this point in the history
Fix #189: Code cleanup
  • Loading branch information
romanstrobl authored Apr 25, 2022
2 parents 3977b3e + 07d125a commit 4bee0df
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 9 deletions.
6 changes: 5 additions & 1 deletion powerauth-data-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<artifactId>powerauth-data-adapter</artifactId>
<groupId>io.getlime.security</groupId>
<version>1.3.0-SNAPSHOT</version>
<version>1.2.5</version>
<packaging>war</packaging>

<name>powerauth-data-adapter</name>
Expand Down Expand Up @@ -84,6 +84,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ public interface DataAdapter {
* @return Response with information whether consent form should be displayed.
* @throws DataAdapterRemoteException Thrown when remote communication fails.
* @throws InvalidOperationContextException Thrown when operation context is invalid.
* @throws InvalidConsentDataException Thrown when consent data is invalid.
*/
InitConsentFormResponse initConsentForm(String userId, String organizationId, OperationContext operationContext) throws DataAdapterRemoteException, InvalidOperationContextException;
InitConsentFormResponse initConsentForm(String userId, String organizationId, OperationContext operationContext) throws DataAdapterRemoteException, InvalidOperationContextException, InvalidConsentDataException;

/**
* Create OAuth 2.0 consent form - prepare HTML text of consent form and add form options.
Expand All @@ -231,8 +232,9 @@ public interface DataAdapter {
* @return Consent form contents with HTML text and form options.
* @throws DataAdapterRemoteException Thrown when remote communication fails.
* @throws InvalidOperationContextException Thrown when operation context is invalid.
* @throws InvalidConsentDataException Thrown when consent options are invalid.
*/
CreateConsentFormResponse createConsentForm(String userId, String organizationId, OperationContext operationContext, String lang) throws DataAdapterRemoteException, InvalidOperationContextException;
CreateConsentFormResponse createConsentForm(String userId, String organizationId, OperationContext operationContext, String lang) throws DataAdapterRemoteException, InvalidOperationContextException, InvalidConsentDataException;

/**
* Validate consent form values and generate response with validation result with optional error messages in case validation fails.
Expand All @@ -244,7 +246,7 @@ public interface DataAdapter {
* @return Consent form validation result with optional error messages in case validation fails.
* @throws DataAdapterRemoteException Thrown when remote communication fails.
* @throws InvalidOperationContextException Thrown when operation context is invalid.
* @throws InvalidConsentDataException In case consent options are invalid.
* @throws InvalidConsentDataException Thrown when consent options are invalid.
*/
ValidateConsentFormResponse validateConsentForm(String userId, String organizationId, OperationContext operationContext, String lang, List<ConsentOption> options) throws DataAdapterRemoteException, InvalidOperationContextException, InvalidConsentDataException;

Expand All @@ -257,7 +259,7 @@ public interface DataAdapter {
* @return Response with result of saving the consent form.
* @throws DataAdapterRemoteException Thrown when remote communication fails.
* @throws InvalidOperationContextException Thrown when operation context is invalid.
* @throws InvalidConsentDataException In case consent options are invalid.
* @throws InvalidConsentDataException Thrown when consent options are invalid.
*/
SaveConsentFormResponse saveConsentForm(String userId, String organizationId, OperationContext operationContext, List<ConsentOption> options) throws DataAdapterRemoteException, InvalidOperationContextException, InvalidConsentDataException;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2019 Wultra s.r.o.
*
* 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 io.getlime.security.powerauth.app.dataadapter.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
* Default Spring Security configuration.
*
* @author Petr Dvorak, [email protected]
*/
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

/**
* Configures HTTP security.
* @param http HTTP security.
* @throws Exception Thrown when configuration fails.
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic().disable();
http.csrf().disable();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ private void initBinder(WebDataBinder binder) {
* @return Initialize consent form response.
* @throws DataAdapterRemoteException In case communication with remote system fails.
* @throws InvalidOperationContextException In case operation context is invalid.
* @throws InvalidConsentDataException In case consent options are invalid.
*/
@PostMapping(value = "/init")
public ObjectResponse<InitConsentFormResponse> initConsentForm(@Valid @RequestBody ObjectRequest<InitConsentFormRequest> request) throws DataAdapterRemoteException, InvalidOperationContextException {
public ObjectResponse<InitConsentFormResponse> initConsentForm(@Valid @RequestBody ObjectRequest<InitConsentFormRequest> request) throws DataAdapterRemoteException, InvalidOperationContextException, InvalidConsentDataException {
logger.info("Received initConsentForm request for user: {}, operation ID: {}",
request.getRequestObject().getUserId(), request.getRequestObject().getOperationContext().getId());
InitConsentFormRequest createRequest = request.getRequestObject();
Expand All @@ -102,9 +103,10 @@ public ObjectResponse<InitConsentFormResponse> initConsentForm(@Valid @RequestBo
* @return Create consent form response.
* @throws DataAdapterRemoteException In case communication with remote system fails.
* @throws InvalidOperationContextException In case operation context is invalid.
* @throws InvalidConsentDataException In case consent options are invalid.
*/
@PostMapping(value = "/create")
public ObjectResponse<CreateConsentFormResponse> createConsentForm(@Valid @RequestBody ObjectRequest<CreateConsentFormRequest> request) throws DataAdapterRemoteException, InvalidOperationContextException {
public ObjectResponse<CreateConsentFormResponse> createConsentForm(@Valid @RequestBody ObjectRequest<CreateConsentFormRequest> request) throws DataAdapterRemoteException, InvalidOperationContextException, InvalidConsentDataException {
logger.info("Received createConsentForm request for user: {}, operation ID: {}",
request.getRequestObject().getUserId(), request.getRequestObject().getOperationContext().getId());
CreateConsentFormRequest createRequest = request.getRequestObject();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2017 Wultra s.r.o.
*
* 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 io.getlime.security.powerauth.app.dataadapter.impl.service;

import io.getlime.security.powerauth.app.dataadapter.api.DataAdapter;
Expand Down Expand Up @@ -405,13 +420,13 @@ public VerifyCertificateResponse verifyClientCertificate(String userId, String o
}

@Override
public InitConsentFormResponse initConsentForm(String userId, String organizationId, OperationContext operationContext) throws DataAdapterRemoteException, InvalidOperationContextException {
public InitConsentFormResponse initConsentForm(String userId, String organizationId, OperationContext operationContext) throws DataAdapterRemoteException, InvalidOperationContextException, InvalidConsentDataException {
// Override this logic in case consent form should be displayed conditionally for given operation context.
return new InitConsentFormResponse(true);
}

@Override
public CreateConsentFormResponse createConsentForm(String userId, String organizationId, OperationContext operationContext, String lang) throws DataAdapterRemoteException, InvalidOperationContextException {
public CreateConsentFormResponse createConsentForm(String userId, String organizationId, OperationContext operationContext, String lang) throws DataAdapterRemoteException, InvalidOperationContextException, InvalidConsentDataException {
// Fallback to English for unsupported languages, see: https://github.com/wultra/powerauth-webflow-customization/issues/104
if (!"cs".equals(lang) && !"en".equals(lang)) {
lang = "en";
Expand Down

0 comments on commit 4bee0df

Please sign in to comment.