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
1 parent
df20a2c
commit d0d9965
Showing
23 changed files
with
291 additions
and
116 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
80 changes: 80 additions & 0 deletions
80
...ty/src/main/java/org/neo4j/server/security/enterprise/auth/plugin/PluginApiAuthToken.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,80 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.server.security.enterprise.auth.plugin; | ||
|
||
import java.util.Map; | ||
|
||
import org.neo4j.kernel.api.security.exception.InvalidAuthTokenException; | ||
import org.neo4j.server.security.enterprise.auth.plugin.api.AuthToken; | ||
|
||
import static org.neo4j.kernel.api.security.AuthToken.PRINCIPAL; | ||
import static org.neo4j.kernel.api.security.AuthToken.CREDENTIALS; | ||
import static org.neo4j.kernel.api.security.AuthToken.PARAMETERS; | ||
|
||
public class PluginApiAuthToken implements AuthToken | ||
{ | ||
private final String principal; | ||
private final char[] credentials; | ||
private final Map<String,Object> parameters; | ||
|
||
private PluginApiAuthToken( String principal, char[] credentials, Map<String,Object> parameters ) | ||
{ | ||
this.principal = principal; | ||
this.credentials = credentials; | ||
this.parameters = parameters; | ||
} | ||
|
||
@Override | ||
public String getPrincipal() | ||
{ | ||
return principal; | ||
} | ||
|
||
@Override | ||
public char[] getCredentials() | ||
{ | ||
return credentials; | ||
} | ||
|
||
@Override | ||
public Map<String,Object> getParameters() | ||
{ | ||
return parameters; | ||
} | ||
|
||
public static AuthToken of( String principal, char[] credentials ) | ||
{ | ||
return new PluginApiAuthToken( principal, credentials, null ); | ||
} | ||
|
||
public static AuthToken of( String principal, char[] credentials, Map<String,Object> parameters ) | ||
{ | ||
return new PluginApiAuthToken( principal, credentials, parameters ); | ||
} | ||
|
||
public static AuthToken createFromMap( Map<String,Object> authTokenMap ) throws InvalidAuthTokenException | ||
{ | ||
String principal = org.neo4j.kernel.api.security.AuthToken.safeCast( PRINCIPAL, authTokenMap ); | ||
String credentials = org.neo4j.kernel.api.security.AuthToken.safeCast( CREDENTIALS, authTokenMap ); | ||
Map<String,Object> parameters = org.neo4j.kernel.api.security.AuthToken.safeCastMap( PARAMETERS, authTokenMap ); | ||
|
||
return PluginApiAuthToken.of( principal, credentials.toCharArray(), parameters ); | ||
} | ||
} |
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
.../src/main/java/org/neo4j/server/security/enterprise/auth/plugin/PluginShiroAuthToken.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 @@ | ||
/* | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.server.security.enterprise.auth.plugin; | ||
|
||
import org.apache.shiro.authc.AuthenticationToken; | ||
|
||
import java.util.Map; | ||
|
||
import org.neo4j.server.security.enterprise.auth.ShiroAuthToken; | ||
|
||
/** | ||
* Version of ShiroAuthToken that returns credentials as a char array | ||
* so that it is compatible for credentials matching with the | ||
* cacheable auth info results returned by the plugin API | ||
*/ | ||
public class PluginShiroAuthToken extends ShiroAuthToken | ||
{ | ||
private PluginShiroAuthToken( Map<String,Object> authTokenMap ) | ||
{ | ||
super( authTokenMap ); | ||
} | ||
|
||
@Override | ||
public Object getCredentials() | ||
{ | ||
return ((String) super.getCredentials()).toCharArray(); | ||
} | ||
|
||
public static PluginShiroAuthToken of( ShiroAuthToken shiroAuthToken ) | ||
{ | ||
return new PluginShiroAuthToken( shiroAuthToken.getAuthTokenMap() ); | ||
} | ||
|
||
public static PluginShiroAuthToken of( AuthenticationToken authenticationToken ) | ||
{ | ||
ShiroAuthToken shiroAuthToken = (ShiroAuthToken) authenticationToken; | ||
return PluginShiroAuthToken.of( shiroAuthToken ); | ||
} | ||
} |
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.