-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
204 additions
and
16 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...ources/src/main/java/org/eclipse/kapua/app/api/resources/v1/resources/UserCredential.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,51 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.app.api.resources.v1.resources; | ||
|
||
import org.eclipse.kapua.KapuaException; | ||
import org.eclipse.kapua.app.api.core.model.ScopeId; | ||
import org.eclipse.kapua.locator.KapuaLocator; | ||
import org.eclipse.kapua.service.KapuaService; | ||
import org.eclipse.kapua.service.authentication.credential.Credential; | ||
import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest; | ||
import org.eclipse.kapua.service.authentication.user.UserCredentialService; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("{scopeId}/user/credentials") | ||
public class UserCredential { | ||
private final KapuaLocator locator = KapuaLocator.getInstance(); | ||
private final UserCredentialService userCredentialService = locator.getService(UserCredentialService.class); | ||
|
||
|
||
/** | ||
* Change the user password | ||
* | ||
* @param scopeId The {@link ScopeId} to use in the request. | ||
* @param passwordChangeRequest The {@link PasswordChangeRequest} represents the changing | ||
* @return The updated {@link Credential} | ||
* @throws KapuaException Whenever something bad happens. See specific {@link KapuaService} exceptions. | ||
*/ | ||
@Path("/password") | ||
@POST | ||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | ||
public Credential newPassword(@PathParam("scopeId") ScopeId scopeId, PasswordChangeRequest passwordChangeRequest) throws KapuaException { | ||
return userCredentialService.changePasswordRequest(passwordChangeRequest); | ||
} | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
...pi/src/main/java/org/eclipse/kapua/service/authentication/user/UserCredentialFactory.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,19 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.authentication.user; | ||
|
||
import org.eclipse.kapua.model.KapuaObjectFactory; | ||
|
||
public interface UserCredentialFactory extends KapuaObjectFactory { | ||
PasswordChangeRequest newPasswordChangeRequest(); | ||
} |
35 changes: 35 additions & 0 deletions
35
...rc/main/java/org/eclipse/kapua/service/authentication/user/UserCredentialXmlRegistry.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,35 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.authentication.user; | ||
|
||
import org.eclipse.kapua.locator.KapuaLocator; | ||
|
||
import javax.xml.bind.annotation.XmlRegistry; | ||
|
||
@XmlRegistry | ||
public class UserCredentialXmlRegistry { | ||
|
||
private static final KapuaLocator LOCATOR = KapuaLocator.getInstance(); | ||
private static final UserCredentialFactory USER_CREDENTIAL_FACTORY = LOCATOR.getFactory(UserCredentialFactory.class); | ||
|
||
|
||
/** | ||
* Creates a new credential instance | ||
* | ||
* @return | ||
*/ | ||
public PasswordChangeRequest newPasswordChangeRequest() { | ||
return USER_CREDENTIAL_FACTORY.newPasswordChangeRequest(); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...n/java/org/eclipse/kapua/service/authentication/user/shiro/PasswordChangeRequestImpl.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,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.authentication.user.shiro; | ||
|
||
import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest; | ||
|
||
public class PasswordChangeRequestImpl implements PasswordChangeRequest { | ||
private String newPassword; | ||
private String oldPassword; | ||
|
||
|
||
@Override | ||
public String getOldPassword() { | ||
return oldPassword; | ||
} | ||
|
||
|
||
@Override | ||
public void setOldPassword(String oldPassword) { | ||
this.oldPassword = oldPassword; | ||
} | ||
|
||
|
||
@Override | ||
public String getNewPassword() { | ||
return newPassword; | ||
} | ||
|
||
|
||
@Override | ||
public void setNewPassword(String newPassword) { | ||
this.newPassword = newPassword; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...n/java/org/eclipse/kapua/service/authentication/user/shiro/UserCredentialFactoryImpl.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,26 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023, 2022 Eurotech and/or its affiliates and others | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Eurotech - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.kapua.service.authentication.user.shiro; | ||
|
||
import org.eclipse.kapua.service.authentication.user.PasswordChangeRequest; | ||
import org.eclipse.kapua.service.authentication.user.UserCredentialFactory; | ||
|
||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
public class UserCredentialFactoryImpl implements UserCredentialFactory { | ||
@Override | ||
public PasswordChangeRequest newPasswordChangeRequest() { | ||
return new PasswordChangeRequestImpl(); | ||
} | ||
} |
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