-
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.3 -> Add auth system based on bcrypt
- Loading branch information
Showing
35 changed files
with
860 additions
and
122 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
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
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
67 changes: 67 additions & 0 deletions
67
src/main/java/org/panda_lang/nanomaven/console/commands/MemberCommand.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,67 @@ | ||
/* | ||
* Copyright (c) 2017 Dzikoysk | ||
* | ||
* 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 org.panda_lang.nanomaven.console.commands; | ||
|
||
import org.panda_lang.nanomaven.NanoMaven; | ||
import org.panda_lang.nanomaven.console.NanoCommand; | ||
import org.panda_lang.nanomaven.server.auth.NanoProject; | ||
import org.panda_lang.nanomaven.server.auth.NanoProjectsManager; | ||
import org.panda_lang.nanomaven.server.auth.NanoUser; | ||
import org.panda_lang.nanomaven.server.auth.NanoUsersManager; | ||
|
||
public class MemberCommand implements NanoCommand { | ||
|
||
private final String projectName; | ||
private final String username; | ||
|
||
public MemberCommand(String projectName, String username) { | ||
this.projectName = projectName; | ||
this.username = username; | ||
} | ||
|
||
@Override | ||
public void call(NanoMaven nanoMaven) { | ||
NanoUsersManager usersManager = nanoMaven.getUsersManager(); | ||
NanoProjectsManager projectsManager = nanoMaven.getProjectsManager(); | ||
|
||
if (!projectName.contains("/")) { | ||
NanoMaven.getLogger().warn("GroupId or ArtifactId is not specified"); | ||
return; | ||
} | ||
|
||
NanoProject nanoProject = projectsManager.getProject(projectName); | ||
|
||
if (nanoProject == null) { | ||
NanoMaven.getLogger().warn("Project " + projectName + " doesn't exists"); | ||
return; | ||
} | ||
|
||
NanoUser nanoUser = usersManager.getUser(username); | ||
|
||
if (nanoUser == null) { | ||
NanoMaven.getLogger().warn("User " + username + " doesn't exists"); | ||
return; | ||
} | ||
|
||
nanoProject.addUser(nanoUser); | ||
nanoUser.addProject(nanoProject); | ||
|
||
projectsManager.save(); | ||
NanoMaven.getLogger().info("User " + username + " has been added to the '" + projectName + "' project"); | ||
} | ||
|
||
} |
48 changes: 0 additions & 48 deletions
48
src/main/java/org/panda_lang/nanomaven/console/commands/NanoMavenCommand.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
src/main/java/org/panda_lang/nanomaven/console/commands/ProjectCommand.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,57 @@ | ||
/* | ||
* Copyright (c) 2017 Dzikoysk | ||
* | ||
* 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 org.panda_lang.nanomaven.console.commands; | ||
|
||
import org.panda_lang.nanomaven.NanoMaven; | ||
import org.panda_lang.nanomaven.console.NanoCommand; | ||
import org.panda_lang.nanomaven.server.auth.NanoProject; | ||
import org.panda_lang.nanomaven.server.auth.NanoProjectsManager; | ||
|
||
public class ProjectCommand implements NanoCommand { | ||
|
||
private final String projectName; | ||
|
||
public ProjectCommand(String projectName) { | ||
this.projectName = projectName; | ||
} | ||
|
||
@Override | ||
public void call(NanoMaven nanoMaven) { | ||
NanoProjectsManager projectsManager = nanoMaven.getProjectsManager(); | ||
|
||
if (!projectName.contains("/")) { | ||
NanoMaven.getLogger().warn("GroupId or ArtifactId is not specified"); | ||
return; | ||
} | ||
|
||
NanoProject nanoProject = projectsManager.getProject(projectName); | ||
|
||
if (nanoProject != null) { | ||
NanoMaven.getLogger().warn("Project " + projectName + " exists"); | ||
return; | ||
} | ||
|
||
NanoMaven.getLogger().info("Creating project..."); | ||
|
||
NanoProject project = new NanoProject(projectName); | ||
projectsManager.addProject(project); | ||
projectsManager.save(); | ||
|
||
NanoMaven.getLogger().info("Project " + project.getProjectName() + " has been created"); | ||
} | ||
|
||
} |
Oops, something went wrong.