<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-aaf</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
<packaging>jar</packaging>
<name>ONAP Portal SDK AAF Authorization</name>
import java.io.Serializable;
-public class ExternalAccessPerms implements Serializable, Comparable {
+public class ExternalAccessPerms implements Serializable {
/**
*
this.description = description;
}
- @Override
- public int compareTo(Object obj) {
- ExternalAccessPerms other = (ExternalAccessPerms) obj;
-
- String c1 = getInstance();
- String c2 = other.getInstance();
-
- return (c1 == null || c2 == null) ? 1 : c1.compareTo(c2);
- }
-
@Override
public int hashCode() {
final int prime = 31;
public String name;
private List<ExternalAccessPerms> perms;
- public ExternalAccessRoleDescription description;
public ExternalAccessRole() {
super();
}
- public ExternalAccessRole(String name, List<ExternalAccessPerms> ecPerms, ExternalAccessRoleDescription description) {
+ public ExternalAccessRole(String name, List<ExternalAccessPerms> ecPerms) {
super();
this.name = name;
this.perms = ecPerms;
- this.description = description;
}
public String getName() {
this.perms = perms;
}
- public ExternalAccessRoleDescription getDescription() {
- return description;
- }
- public void setDescription(ExternalAccessRoleDescription description) {
- this.description = description;
- }
-
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((perms == null) ? 0 : perms.hashCode());
return result;
if (getClass() != obj.getClass())
return false;
ExternalAccessRole other = (ExternalAccessRole) obj;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
if (name == null) {
if (other.name != null)
return false;
+++ /dev/null
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal SDK
- * ===================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- *
- * Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the "License");
- * you may not use this software 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.
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
- *
- * ============LICENSE_END============================================
- *
- *
- */
-package org.onap.portalsdk.external.authorization.domain;
-
-public class ExternalAccessRoleDescription {
-
- private String id;
- private String name;
- private String active;
- private String priority;
- private String appId;
- private String appRoleId;
-
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getActive() {
- return active;
- }
- public void setActive(String active) {
- this.active = active;
- }
- public String getPriority() {
- return priority;
- }
- public void setPriority(String priority) {
- this.priority = priority;
- }
- public String getAppId() {
- return appId;
- }
- public void setAppId(String appId) {
- this.appId = appId;
- }
- public String getAppRoleId() {
- return appRoleId;
- }
- public void setAppRoleId(String appRoleId) {
- this.appRoleId = appRoleId;
- }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((active == null) ? 0 : active.hashCode());
- result = prime * result + ((appId == null) ? 0 : appId.hashCode());
- result = prime * result + ((appRoleId == null) ? 0 : appRoleId.hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((priority == null) ? 0 : priority.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ExternalAccessRoleDescription other = (ExternalAccessRoleDescription) obj;
- if (active == null) {
- if (other.active != null)
- return false;
- } else if (!active.equals(other.active))
- return false;
- if (appId == null) {
- if (other.appId != null)
- return false;
- } else if (!appId.equals(other.appId))
- return false;
- if (appRoleId == null) {
- if (other.appRoleId != null)
- return false;
- } else if (!appRoleId.equals(other.appRoleId))
- return false;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- if (priority == null) {
- if (other.priority != null)
- return false;
- } else if (!priority.equals(other.priority))
- return false;
- return true;
- }
-
-
-
-
-}
.equals(new ExternalAccessPerms("test_type", "test_instance", "*", "test_name")));
}
- @Test
- public void testCompareTo()
- {
- ExternalAccessPerms extPermsDetailTest1 = new ExternalAccessPerms("test_type", "test_instance", "*");
- ExternalAccessPerms extPermsDetailTest2 = new ExternalAccessPerms("test_type", "test_instance", "*",
- "test_name");
- extPermsDetailTest1.setInstance("test_instance");
- extPermsDetailTest2.setInstance("test_instance");
- int result= extPermsDetailTest1.compareTo(extPermsDetailTest2);
- assertEquals(0, result);
- }
-
@Test
public void testHashCode()
{
+++ /dev/null
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal SDK
- * ===================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- *
- * Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the "License");
- * you may not use this software 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.
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * 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.
- *
- * ============LICENSE_END============================================
- *
- *
- */
-package org.onap.portalsdk.external.authorization.domain;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class ExternalAccessRoleDescriptionTest {
-
- public ExternalAccessRoleDescription mockExternalRoleDescriptionTest() {
- ExternalAccessRoleDescription mockExtRoleDesc = new ExternalAccessRoleDescription();
- mockExtRoleDesc.setActive("true");
- mockExtRoleDesc.setAppRoleId("1");
- mockExtRoleDesc.setAppId("1");
- mockExtRoleDesc.setId("1");
- mockExtRoleDesc.setName("test");
- mockExtRoleDesc.setPriority("1");
- return mockExtRoleDesc;
- }
-
- @Test
- public void externalRoleDescriptionTest() {
- ExternalAccessRoleDescription extRoleDesc = new ExternalAccessRoleDescription();
- extRoleDesc.setActive("true");
- extRoleDesc.setAppRoleId("1");
- extRoleDesc.setAppId("1");
- extRoleDesc.setId("1");
- extRoleDesc.setName("test");
- extRoleDesc.setPriority("1");
- assertEquals(extRoleDesc.getActive(), mockExternalRoleDescriptionTest().getActive());
- assertEquals(extRoleDesc.getAppId(), mockExternalRoleDescriptionTest().getAppId());
- assertEquals(extRoleDesc.getAppRoleId(), mockExternalRoleDescriptionTest().getAppRoleId());
- assertEquals(extRoleDesc.getId(), mockExternalRoleDescriptionTest().getId());
- assertEquals(extRoleDesc.getName(), mockExternalRoleDescriptionTest().getName());
- assertEquals(extRoleDesc.getPriority(), mockExternalRoleDescriptionTest().getPriority());
- assertEquals(true, extRoleDesc.equals(mockExternalRoleDescriptionTest()));
- }
-}
public ExternalAccessRole mockExternalAccessRoleTest() {
ExternalAccessRole mockRole = new ExternalAccessRole();
- ExternalAccessRoleDescription roleDesc = new ExternalAccessRoleDescription();
+ String roleDesc = "";
ExternalAccessPerms ecPerm = new ExternalAccessPerms();
List<ExternalAccessPerms> ecPerms = new ArrayList<>();
ecPerm.setAction("test_action");
ecPerm.setType("test_type");
ecPerm.setInstance("test_instance");
ecPerm.setDescription("test_description");
- roleDesc.setActive("true");
- roleDesc.setAppId("1");
mockRole.setName("test_role");
mockRole.setPerms(ecPerms);
- mockRole.setDescription(roleDesc);
return mockRole;
}
public void setUp()
{
mockRole = mockExternalAccessRoleTest();
- role = new ExternalAccessRole(mockRole.getName(), mockRole.getPerms(), mockRole.getDescription());
- role1= new ExternalAccessRole(mockRole.getName(), mockRole.getPerms(), mockRole.getDescription());;
+ role = new ExternalAccessRole(mockRole.getName(), mockRole.getPerms());
+ role1= new ExternalAccessRole(mockRole.getName(), mockRole.getPerms());
}
@Test
assertEquals(role.getName(), mockExternalAccessRoleTest().getName());
assertEquals(role.getPerms(), mockExternalAccessRoleTest().getPerms());
- assertEquals(role.getDescription(), mockExternalAccessRoleTest().getDescription());
}
@Test
mockExtPermsTest.setType("test_type");
mockExtPermsTest.setInstance("test_instance");
mockPerms.add(mockExtPermsTest);
- ExternalAccessRoleDescription mockRoleDesc = new ExternalAccessRoleDescription();
- mockRoleDesc.setActive("true");
- mockRoleDesc.setAppId("1");
- mockRoleDesc.setAppRoleId("1");
- mockRoleDesc.setId("1");
- mockRoleDesc.setPriority("1");
- mockRoleDesc.setName("test");
- mockRoleDesc.setName("com.test.app.rolename");
role.setPerms(mockPerms);
- role.setDescription(mockRoleDesc);
ExternalAccessUserRoleDetail mockExtUserRoleDetailTest = new ExternalAccessUserRoleDetail(role);
return mockExtUserRoleDetailTest;
}
ExternalAccessRole role = extUserRoleDetailTest2.getRole();
assertEquals(role.getName(), mockExternalAccessUserRoleDetailTest().getRole().getName());
assertEquals(role.getPerms(), mockExternalAccessUserRoleDetailTest().getRole().getPerms());
- assertEquals(role.getDescription(), mockExternalAccessUserRoleDetailTest().getRole().getDescription());
}
*/
package org.onap.portalsdk.external.authorization.util;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
import javax.xml.bind.DatatypeConverter;
public void checkNameSpaceMatchingLengthTest() throws Exception {
EcompExternalAuthUtils.checkNameSpaceMatching("com.test.app2.role", "com.test.app2.role.test");
}
-
- @Test
- public void isJsonValidTest() {
- boolean actual = EcompExternalAuthUtils.isJSONValid("{\"test\":\"test\"}");
- assertTrue(actual);
- }
-
- @Test
- public void isJsonValidFailTest() {
- boolean actual = EcompExternalAuthUtils.isJSONValid("{\"test\":\"test\"");
- assertFalse(actual);
- }
}
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<!-- GroupId is inherited from parent -->
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<!-- GroupId is inherited from parent -->
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<!-- GroupId is inherited from parent -->
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<!-- GroupId is inherited from parent -->
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<!-- GroupId is inherited from parent -->
-
/*-
* ============LICENSE_START==========================================
* ONAP Portal SDK
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.portalsdk.external.authorization.domain.ExternalAccessPerms;
import org.onap.portalsdk.external.authorization.domain.ExternalAccessRole;
-import org.onap.portalsdk.external.authorization.domain.ExternalAccessRoleDescription;
import org.onap.portalsdk.external.authorization.domain.ExternalAccessUserRoleDetail;
import org.onap.portalsdk.external.authorization.exception.UserNotFoundException;
import org.onap.portalsdk.external.authorization.service.AAFRestServiceImpl;
@Service("userApiService")
public class UserApiServiceImpl implements UserApiService {
-
private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(UserApiServiceImpl.class);
@Autowired
@Autowired
private AppService appService;
-
-
+
private AAFService aafService = new AAFRestServiceImpl();
@Override
try {
String namespace = EcompExternalAuthProperties
.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_NAMESPACE);
-
+
HttpHeaders headers = getBasicAuthHeaders();
String userRoles = aafService.getUser(orgUserId, request, headers);
ObjectMapper mapper = new ObjectMapper();
.endsWith(EcompExternalAuthUtils.EXT_ROLE_FIELD_ADMIN)
&& !role.getString(EcompExternalAuthUtils.EXT_ROLE_FIELD_NAME)
.endsWith(EcompExternalAuthUtils.EXT_ROLE_FIELD_OWNER)) {
- ExternalAccessRoleDescription ecDesc = new ExternalAccessRoleDescription();
- if (role.has(EcompExternalAuthUtils.EXT_FIELD_DESCRIPTION) && EcompExternalAuthUtils
- .isJSONValid(role.getString(EcompExternalAuthUtils.EXT_FIELD_DESCRIPTION))) {
- ecDesc = mapper.readValue(role.getString(EcompExternalAuthUtils.EXT_FIELD_DESCRIPTION),
- ExternalAccessRoleDescription.class);
- }
List<ExternalAccessPerms> ecPerms = new ArrayList<>();
if (role.has(EcompExternalAuthUtils.EXT_FIELD_PERMS)) {
JSONArray perms = role.getJSONArray(EcompExternalAuthUtils.EXT_FIELD_PERMS);
.constructCollectionType(List.class, ExternalAccessPerms.class));
}
ExternalAccessRole ecRole = new ExternalAccessRole(
- role.getString(EcompExternalAuthUtils.EXT_ROLE_FIELD_NAME), ecPerms, ecDesc);
+ role.getString(EcompExternalAuthUtils.EXT_ROLE_FIELD_NAME), ecPerms);
userRoleDetail = new ExternalAccessUserRoleDetail(ecRole);
userRoleDetailList.add(userRoleDetail);
}
Set userApps = new TreeSet();
for (ExternalAccessUserRoleDetail userRoleDetail : userRoleDetailList) {
ExternalAccessRole ecRole = userRoleDetail.getRole();
- ExternalAccessRoleDescription roleDesc = ecRole.getDescription();
UserApp userApp = new UserApp();
Role role = new Role();
Set roleFunctions = new TreeSet<>();
- if (roleDesc.getName() == null) {
- role.setActive(true);
- role.setName(ecRole.getName());
- } else {
- role.setActive(Boolean.valueOf(roleDesc.getActive()));
- role.setId(Long.valueOf(roleDesc.getAppRoleId()));
- role.setName(roleDesc.getName());
- if (!roleDesc.getPriority().equals(EcompExternalAuthUtils.EXT_NULL_VALUE)) {
- role.setPriority(Integer.valueOf(roleDesc.getPriority()));
- }
- }
+ role.setActive(true);
+ role.setName(ecRole.getName());
for (ExternalAccessPerms extPerm : ecRole.getPerms()) {
RoleFunction roleFunction = new RoleFunction();
roleFunction.setCode(extPerm.getInstance());
@Override
public List<RoleFunction> getRoleFunctions(String orgUserId) throws Exception {
HttpHeaders headers = getBasicAuthHeaders();
- return aafService.getRoleFunctions(orgUserId,headers);
+ return aafService.getRoleFunctions(orgUserId, headers);
}
-
+ @SuppressWarnings("unused")
private ResponseEntity<String> getPermsFromExternalAuthSystem(HttpEntity<String> entity, String endPoint) {
ResponseEntity<String> getResponse = template.exchange(
EcompExternalAuthProperties.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_URL) + endPoint,
result = CipherUtil.decryptPKC(encrypted,
SystemProperties.getProperty(SystemProperties.Decryption_Key));
} catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger,"decryptedPassword failed", e);
+ logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e);
throw e;
}
}
return result;
}
-
-
+
private SearchResult loadSearchResultData(PostSearchBean searchCriteria) throws NamingException {
return ldapService.searchPost(searchCriteria.getUser(), searchCriteria.getSortBy1(),
searchCriteria.getSortBy2(), searchCriteria.getSortBy3(), searchCriteria.getPageNo(),
String encryptedPass = EcompExternalAuthProperties
.getProperty(EcompExternalAuthProperties.EXTERNAL_AUTH_PASSWORD);
String appPassword = decryptPass(encryptedPass);
- return aafService.checkUserExists(username,password, appPassword);
+ return aafService.checkUserExists(username, password, appPassword);
}
-
-
@Override
public List<ExternalAccessPerms> getIfUserPermsExists(String username) throws Exception {
HttpHeaders headers = getBasicAuthHeaders();
- return aafService.getIfUserPermsExists(username,headers);
+ return aafService.getIfUserPermsExists(username, headers);
}
}
\ No newline at end of file
userRolesList.add(mockJsonObjectRole4);
userRolesList.add(mockJsonObjectRole5);
mockJsonObjectFinalUserRole.put("role", userRolesList);
- Mockito.when(EcompExternalAuthUtils.isJSONValid(addDesc)).thenReturn(true);
ResponseEntity<String> response = new ResponseEntity<>(mockJsonObjectFinalUserRole.toString(), HttpStatus.OK);
Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET),
Matchers.<HttpEntity<String>>any(), Matchers.eq(String.class))).thenReturn(response);
String user = mapper.writeValueAsString(userObj());
Mockito.when(aafService.getUser("test123", mockedRequest, headers)).thenReturn(user);
User actual = UserApiServiceImpl.getUser("test123", mockedRequest);
+ assertNull(actual);
}
@Test
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-domain</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
<packaging>jar</packaging>
<name>ONAP Portal SDK Domain</name>
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<!-- GroupId is inherited from parent -->
<dependency>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-logger</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.onap.aaf.authz</groupId>
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-logger</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
<dependencies>
<dependency>
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-music</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
<packaging>jar</packaging>
<name>ONAP Portal SDK Music</name>
<parent>
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
</parent>
<!-- GroupId is inherited from parent -->
<!-- Portal SDK Maven parent project -->
<groupId>org.onap.portal.sdk</groupId>
<artifactId>epsdk-project</artifactId>
- <version>2.5.0</version>
+ <version>2.5.1</version>
<packaging>pom</packaging>
<name>portal-sdk</name>
<url>https://wiki.onap.org/display/DW/Portal</url>