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
30 changed files
with
1,138 additions
and
103 deletions.
There are no files selected for viewing
130 changes: 130 additions & 0 deletions
130
model/src/main/java/org/cloudfoundry/identity/uaa/authentication/GenericPasswordPolicy.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,130 @@ | |||
package org.cloudfoundry.identity.uaa.authentication; | |||
|
|||
import org.cloudfoundry.identity.uaa.provider.PasswordPolicy; | |||
|
|||
/** | |||
* **************************************************************************** | |||
* Cloud Foundry | |||
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved. | |||
* <p> | |||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | |||
* You may not use this product except in compliance with the License. | |||
* <p> | |||
* This product includes a number of subcomponents with | |||
* separate copyright notices and license terms. Your use of these | |||
* subcomponents is subject to the terms and conditions of the | |||
* subcomponent's license, as noted in the LICENSE file. | |||
* ***************************************************************************** | |||
*/ | |||
public abstract class GenericPasswordPolicy <T extends GenericPasswordPolicy<T>> { | |||
|
|||
private int minLength; | |||
private int maxLength; | |||
private int requireUpperCaseCharacter; | |||
private int requireLowerCaseCharacter; | |||
private int requireDigit; | |||
private int requireSpecialCharacter; | |||
|
|||
public GenericPasswordPolicy() { | |||
minLength = maxLength = requireUpperCaseCharacter = requireLowerCaseCharacter = requireDigit = requireSpecialCharacter = -1; | |||
} | |||
|
|||
public GenericPasswordPolicy(int minLength, | |||
int maxLength, | |||
int requireUpperCaseCharacter, | |||
int requireLowerCaseCharacter, | |||
int requireDigit, | |||
int requireSpecialCharacter) { | |||
this.minLength = minLength; | |||
this.maxLength = maxLength; | |||
this.requireUpperCaseCharacter = requireUpperCaseCharacter; | |||
this.requireLowerCaseCharacter = requireLowerCaseCharacter; | |||
this.requireDigit = requireDigit; | |||
this.requireSpecialCharacter = requireSpecialCharacter; | |||
} | |||
|
|||
public int getMinLength() { | |||
return minLength; | |||
} | |||
|
|||
public int getMaxLength() { | |||
return maxLength; | |||
} | |||
|
|||
public int getRequireUpperCaseCharacter() { | |||
return requireUpperCaseCharacter; | |||
} | |||
|
|||
public int getRequireLowerCaseCharacter() { | |||
return requireLowerCaseCharacter; | |||
} | |||
|
|||
public int getRequireDigit() { | |||
return requireDigit; | |||
} | |||
|
|||
public T setMaxLength(int maxLength) { | |||
this.maxLength = maxLength; | |||
return (T)this; | |||
} | |||
|
|||
public T setMinLength(int minLength) { | |||
this.minLength = minLength; | |||
return (T)this; | |||
} | |||
|
|||
public T setRequireDigit(int requireDigit) { | |||
this.requireDigit = requireDigit; | |||
return (T)this; | |||
} | |||
|
|||
public T setRequireLowerCaseCharacter(int requireLowerCaseCharacter) { | |||
this.requireLowerCaseCharacter = requireLowerCaseCharacter; | |||
return (T)this; | |||
} | |||
|
|||
public T setRequireUpperCaseCharacter(int requireUpperCaseCharacter) { | |||
this.requireUpperCaseCharacter = requireUpperCaseCharacter; | |||
return (T)this; | |||
} | |||
|
|||
public int getRequireSpecialCharacter() { | |||
return requireSpecialCharacter; | |||
} | |||
|
|||
public T setRequireSpecialCharacter(int requireSpecialCharacter) { | |||
this.requireSpecialCharacter = requireSpecialCharacter; | |||
return (T)this; | |||
} | |||
|
|||
public boolean allPresentAndPositive() { | |||
return minLength >= 0 && maxLength >= 0 && requireUpperCaseCharacter >= 0 && requireLowerCaseCharacter >= 0 && requireDigit >= 0 && requireSpecialCharacter >= 0; | |||
} | |||
|
|||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) return true; | |||
if (o == null || getClass() != o.getClass()) return false; | |||
|
|||
PasswordPolicy that = (PasswordPolicy) o; | |||
|
|||
if (getMinLength() != that.getMinLength()) return false; | |||
if (getMaxLength() != that.getMaxLength()) return false; | |||
if (getRequireUpperCaseCharacter() != that.getRequireUpperCaseCharacter()) return false; | |||
if (getRequireLowerCaseCharacter() != that.getRequireLowerCaseCharacter()) return false; | |||
if (getRequireDigit() != that.getRequireDigit()) return false; | |||
if (getRequireSpecialCharacter() != that.getRequireSpecialCharacter()) return false; | |||
return true; | |||
} | |||
|
|||
@Override | |||
public int hashCode() { | |||
int result = getMinLength(); | |||
result = 31 * result + getMaxLength(); | |||
result = 31 * result + getRequireUpperCaseCharacter(); | |||
result = 31 * result + getRequireLowerCaseCharacter(); | |||
result = 31 * result + getRequireDigit(); | |||
result = 31 * result + getRequireSpecialCharacter(); | |||
return result; | |||
} | |||
} |
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
77 changes: 77 additions & 0 deletions
77
model/src/main/java/org/cloudfoundry/identity/uaa/zone/ClientSecretPolicy.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,77 @@ | |||
package org.cloudfoundry.identity.uaa.zone; | |||
|
|||
import org.cloudfoundry.identity.uaa.authentication.GenericPasswordPolicy; | |||
|
|||
/** | |||
* **************************************************************************** | |||
* Cloud Foundry | |||
* Copyright (c) [2009-2015] Pivotal Software, Inc. All Rights Reserved. | |||
* <p> | |||
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). | |||
* You may not use this product except in compliance with the License. | |||
* <p> | |||
* This product includes a number of subcomponents with | |||
* separate copyright notices and license terms. Your use of these | |||
* subcomponents is subject to the terms and conditions of the | |||
* subcomponent's license, as noted in the LICENSE file. | |||
* ***************************************************************************** | |||
*/ | |||
public class ClientSecretPolicy extends GenericPasswordPolicy<ClientSecretPolicy> { | |||
public static final String CLIENT_SECRET_POLICY_FIELD = "clientSecretPolicy"; | |||
|
|||
private int expireSecretInMonths; | |||
|
|||
public ClientSecretPolicy() { | |||
super(); | |||
setExpireSecretInMonths(-1); | |||
} | |||
|
|||
public ClientSecretPolicy(int minLength, | |||
int maxLength, | |||
int requireUpperCaseCharacter, | |||
int requireLowerCaseCharacter, | |||
int requireDigit, | |||
int requireSpecialCharacter, | |||
int expireSecretInMonths) { | |||
super(minLength, | |||
maxLength, | |||
requireUpperCaseCharacter, | |||
requireLowerCaseCharacter, | |||
requireDigit, | |||
requireSpecialCharacter); | |||
this.setExpireSecretInMonths(expireSecretInMonths); | |||
} | |||
|
|||
public int getExpireSecretInMonths() { | |||
return expireSecretInMonths; | |||
} | |||
|
|||
public ClientSecretPolicy setExpireSecretInMonths(int expireSecretInMonths) { | |||
this.expireSecretInMonths = expireSecretInMonths; | |||
return this; | |||
} | |||
|
|||
@Override | |||
public boolean allPresentAndPositive() { | |||
return super.allPresentAndPositive() && expireSecretInMonths >= 0; | |||
} | |||
|
|||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) return true; | |||
if (o == null || getClass() != o.getClass()) return false; | |||
if (!super.equals(o)) return false; | |||
|
|||
ClientSecretPolicy that = (ClientSecretPolicy) o; | |||
|
|||
return expireSecretInMonths == that.expireSecretInMonths; | |||
|
|||
} | |||
|
|||
@Override | |||
public int hashCode() { | |||
int result = super.hashCode(); | |||
result = 31 * result + expireSecretInMonths; | |||
return result; | |||
} | |||
} |
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
10 changes: 10 additions & 0 deletions
10
.../main/java/org/cloudfoundry/identity/uaa/authentication/ClientSecretExpiredException.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,10 @@ | |||
package org.cloudfoundry.identity.uaa.authentication; | |||
|
|||
|
|||
import org.springframework.security.authentication.BadCredentialsException; | |||
|
|||
public class ClientSecretExpiredException extends BadCredentialsException { | |||
public ClientSecretExpiredException(String msg) { | |||
super(msg); | |||
} | |||
} |
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.