-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upstream: b=master,r=2988468ed6d39b4ad39860ae9b3edd47c25ebc4f,t=2017-…
…03-12-1317-36819
- Loading branch information
1 parent
92ce845
commit 57cb13f
Showing
35 changed files
with
578 additions
and
103 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
56 changes: 56 additions & 0 deletions
56
components/nexus-core/src/main/java/org/sonatype/nexus/internal/commands/LoginAction.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,56 @@ | ||
/* | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2008-present Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
* Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
*/ | ||
package org.sonatype.nexus.internal.commands; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
import org.sonatype.nexus.security.SecurityHelper; | ||
|
||
import org.apache.karaf.shell.api.action.Action; | ||
import org.apache.karaf.shell.api.action.Command; | ||
import org.apache.karaf.shell.api.action.Option; | ||
import org.apache.shiro.authc.UsernamePasswordToken; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* An action to get a logged in user in the console. | ||
* | ||
* @since 3.3 | ||
*/ | ||
@Named | ||
@Command(name = "login", scope = "nexus", description = "Put a user in context") | ||
public class LoginAction | ||
implements Action | ||
{ | ||
private final SecurityHelper securityHelper; | ||
|
||
@Option(name = "-u", aliases = { "--username" }, description = "Username to login with", required = true) | ||
String username; | ||
|
||
@Option(name = "-p", aliases = { "--password" }, description = "Password to login with", required = true) | ||
String password; | ||
|
||
@Inject | ||
public LoginAction(final SecurityHelper securityHelper) { | ||
this.securityHelper = checkNotNull(securityHelper); | ||
} | ||
|
||
@Override | ||
public Object execute() throws Exception { | ||
securityHelper.subject().login(new UsernamePasswordToken(username, password)); | ||
return null; | ||
} | ||
} | ||
|
48 changes: 48 additions & 0 deletions
48
components/nexus-core/src/main/java/org/sonatype/nexus/internal/commands/LogoutAction.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,48 @@ | ||
/* | ||
* Sonatype Nexus (TM) Open Source Version | ||
* Copyright (c) 2008-present Sonatype, Inc. | ||
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions. | ||
* | ||
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0, | ||
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. | ||
* | ||
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks | ||
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the | ||
* Eclipse Foundation. All other trademarks are the property of their respective owners. | ||
*/ | ||
package org.sonatype.nexus.internal.commands; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
|
||
import org.sonatype.nexus.security.SecurityHelper; | ||
|
||
import org.apache.karaf.shell.api.action.Action; | ||
import org.apache.karaf.shell.api.action.Command; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* An action to logout the currently logged in user in the console. | ||
* | ||
* @since 3.3 | ||
*/ | ||
@Named | ||
@Command(name = "logout", scope = "nexus", description = "Remove a user from context") | ||
public class LogoutAction | ||
implements Action | ||
{ | ||
private final SecurityHelper securityHelper; | ||
|
||
@Inject | ||
public LogoutAction(final SecurityHelper securityHelper) { | ||
this.securityHelper = checkNotNull(securityHelper); | ||
} | ||
|
||
@Override | ||
public Object execute() throws Exception { | ||
securityHelper.subject().logout(); | ||
return null; | ||
} | ||
} | ||
|
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
Oops, something went wrong.