Commit 1d2a8015 authored by michael.simon's avatar michael.simon
Browse files

refactoring ecp rest login (again)

parent 8d296ca8
......@@ -34,6 +34,16 @@ public class PasswordUtil {
if (hashMethod.equals("SSHA")) {
//@TODO Implement apacheds style salted sha-1
String hashPasswordBlank = getPassword(hashPassword);
byte[] pwAndSalt = Base64.decodeBase64(hashPasswordBlank);
//SHA-1 is 20 bytes long
int saltLength = pwAndSalt.length - 20;
byte[] pw = new byte[20];
byte[] salt = new byte[saltLength];
System.arraycopy(pwAndSalt, 0, pw, 0, pw.length);
System.arraycopy(pwAndSalt, pw.length, salt, 0, saltLength);
return Boolean.FALSE;
}
else {
......@@ -48,12 +58,23 @@ public class PasswordUtil {
}
}
private String getPassword(String hashPassword) {
if (hashPassword.matches("^\\{(.+)\\|(.+)\\}$")) {
return hashPassword.replaceAll("^\\{(.+)\\|(.+)\\}$", "$2");
}
else if (hashPassword.matches("^\\{(.+)\\}(.+)$")) {
return hashPassword.replaceAll("^\\{(.+)\\|(.+)\\}$", "$2");
}
else
return null;
}
private String getHashMethod(String hashPassword) {
if (hashPassword.matches("^{(.*)|(.*)}$")) {
return hashPassword.split("|")[0].substring(1);
if (hashPassword.matches("^\\{(.+)\\|(.+)\\}$")) {
return hashPassword.replaceAll("^\\{(.+)\\|(.+)\\}$", "$1");
}
else if (hashPassword.matches("^{(.*)}(.*)$")) {
return hashPassword.split("}")[0].substring(1);
else if (hashPassword.matches("^\\{(.+)\\}(.+)$")) {
return hashPassword.replaceAll("^\\{(.+)\\|(.+)\\}$", "$1");
}
else
return null;
......
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
public class GenericRestInterfaceException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
public GenericRestInterfaceException(String message) {
super(message);
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class GenericRestInterfaceExceptionMapper implements ExceptionMapper<GenericRestInterfaceException> {
@Override
public Response toResponse(GenericRestInterfaceException ex) {
return Response.status(500).entity(ex.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
public class NoDelegationConfiguredException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
public NoDelegationConfiguredException(String message) {
super(message);
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class NoDelegationConfiguredExceptionMapper implements ExceptionMapper<NoDelegationConfiguredException> {
@Override
public Response toResponse(NoDelegationConfiguredException ex) {
return Response.status(404).entity(ex.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}
package edu.kit.scc.webreg.rest.exc;
public class NoEcpSupportException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
public NoEcpSupportException() {
super();
}
public NoEcpSupportException(String message, Throwable cause) {
super(message, cause);
}
public NoEcpSupportException(String message) {
super(message);
}
public NoEcpSupportException(Throwable cause) {
super(cause);
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class NoEcpSupportExceptionMapper implements ExceptionMapper<NoEcpSupportException> {
@Override
public Response toResponse(NoEcpSupportException ex) {
return Response.status(402).entity(ex.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}
package edu.kit.scc.webreg.rest.exc;
public class NoHostnameConfiguredException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
public NoHostnameConfiguredException() {
super();
}
public NoHostnameConfiguredException(String message, Throwable cause) {
super(message, cause);
}
public NoHostnameConfiguredException(String message) {
super(message);
}
public NoHostnameConfiguredException(Throwable cause) {
super(cause);
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class NoHostnameConfiguredExceptionMapper implements ExceptionMapper<NoHostnameConfiguredException> {
@Override
public Response toResponse(NoHostnameConfiguredException ex) {
return Response.status(402).entity(ex.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}
package edu.kit.scc.webreg.rest.exc;
public class NoIdpForScopeException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
public NoIdpForScopeException() {
super();
}
public NoIdpForScopeException(String message, Throwable cause) {
super(message, cause);
}
public NoIdpForScopeException(String message) {
super(message);
}
public NoIdpForScopeException(Throwable cause) {
super(cause);
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class NoIdpForScopeExceptionMapper implements ExceptionMapper<NoIdpForScopeException> {
@Override
public Response toResponse(NoIdpForScopeException ex) {
return Response.status(404).entity(ex.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}
package edu.kit.scc.webreg.rest.exc;
public class NoIdpFoundException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
public NoIdpFoundException() {
super();
}
public NoIdpFoundException(String message, Throwable cause) {
super(message, cause);
}
public NoIdpFoundException(String message) {
super(message);
}
public NoIdpFoundException(Throwable cause) {
super(cause);
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class NoIdpFoundExceptionMapper implements ExceptionMapper<NoIdpFoundException> {
@Override
public Response toResponse(NoIdpFoundException ex) {
return Response.status(402).entity(ex.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}
package edu.kit.scc.webreg.rest.exc;
public class NoScopedUsernameException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
public NoScopedUsernameException() {
super();
}
public NoScopedUsernameException(String message, Throwable cause) {
super(message, cause);
}
public NoScopedUsernameException(String message) {
super(message);
}
public NoScopedUsernameException(Throwable cause) {
super(cause);
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class NoScopedUsernameExceptionMapper implements ExceptionMapper<NoScopedUsernameException> {
@Override
public Response toResponse(NoScopedUsernameException ex) {
return Response.status(404).entity(ex.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}
......@@ -10,12 +10,28 @@
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import java.util.List;
import edu.kit.scc.webreg.drools.UnauthorizedUser;
public class UnauthorizedException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
private List<UnauthorizedUser> unauthList;
public UnauthorizedException(List<UnauthorizedUser> unauthList) {
super();
this.unauthList = unauthList;
}
public UnauthorizedException(String message) {
super(message);
}
public List<UnauthorizedUser> getUnauthList() {
return unauthList;
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
public class UserNotRegisteredException extends RestInterfaceException {
private static final long serialVersionUID = 1L;
public UserNotRegisteredException(String message) {
super(message);
}
}
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.rest.exc;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
@Provider
public class UserNotRegisteredExceptionMapper implements ExceptionMapper<UserNotRegisteredException> {
@Override
public Response toResponse(UserNotRegisteredException ex) {
return Response.status(404).entity(ex.getMessage())
.type(MediaType.TEXT_PLAIN).build();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment