-
Notifications
You must be signed in to change notification settings - Fork 0
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
Alexis
committed
Dec 22, 2018
1 parent
6eb5fbb
commit 3b644c5
Showing
42 changed files
with
2,239 additions
and
398 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
83 changes: 83 additions & 0 deletions
83
src/main/java/com/github/alexisjehan/javanilla/crypto/StandardKeyFactories.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,83 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2018 Alexis Jehan | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
package com.github.alexisjehan.javanilla.crypto; | ||
|
||
import java.security.KeyFactory; | ||
import java.security.NoSuchAlgorithmException; | ||
|
||
/** | ||
* <p>A {@link KeyFactory} factory to get standard instances without throwing checked exceptions.</p> | ||
* @since 1.3.1 | ||
*/ | ||
public final class StandardKeyFactories { | ||
|
||
/** | ||
* <p>Constructor not available.</p> | ||
* @since 1.3.1 | ||
*/ | ||
private StandardKeyFactories() { | ||
// Not available | ||
} | ||
|
||
/** | ||
* <p>Get a new "DiffieHellman" {@code KeyFactory} instance.</p> | ||
* @return a "DiffieHellman" {@code KeyFactory} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static KeyFactory getDiffieHellmanInstance() { | ||
return getInstance("DiffieHellman"); | ||
} | ||
|
||
/** | ||
* <p>Get a new "DSA" {@code KeyFactory} instance.</p> | ||
* @return a "DSA" {@code KeyFactory} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static KeyFactory getDsaInstance() { | ||
return getInstance("DSA"); | ||
} | ||
|
||
/** | ||
* <p>Get a new "RSA" {@code KeyFactory} instance.</p> | ||
* @return a "RSA" {@code KeyFactory} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static KeyFactory getRsaInstance() { | ||
return getInstance("RSA"); | ||
} | ||
|
||
/** | ||
* <p>Get a new {@code KeyFactory} instance without throwing {@code NoSuchAlgorithmException}.</p> | ||
* @param algorithm the {@code KeyFactory} algorithm | ||
* @return a {@code KeyFactory} instance of the provided algorithm | ||
* @since 1.3.1 | ||
*/ | ||
private static KeyFactory getInstance(final String algorithm) { | ||
try { | ||
return KeyFactory.getInstance(algorithm); | ||
} catch (final NoSuchAlgorithmException e) { | ||
throw new AssertionError(e); | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
src/main/java/com/github/alexisjehan/javanilla/crypto/StandardKeyPairGenerators.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,83 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2018 Alexis Jehan | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
package com.github.alexisjehan.javanilla.crypto; | ||
|
||
import java.security.KeyPairGenerator; | ||
import java.security.NoSuchAlgorithmException; | ||
|
||
/** | ||
* <p>A {@link KeyPairGenerator} factory to get standard instances without throwing checked exceptions.</p> | ||
* @since 1.3.1 | ||
*/ | ||
public final class StandardKeyPairGenerators { | ||
|
||
/** | ||
* <p>Constructor not available.</p> | ||
* @since 1.3.1 | ||
*/ | ||
private StandardKeyPairGenerators() { | ||
// Not available | ||
} | ||
|
||
/** | ||
* <p>Get a new "DiffieHellman" {@code KeyPairGenerator} instance.</p> | ||
* @return a "DiffieHellman" {@code KeyPairGenerator} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static KeyPairGenerator getDiffieHellmanInstance() { | ||
return getInstance("DiffieHellman"); | ||
} | ||
|
||
/** | ||
* <p>Get a new "DSA" {@code KeyPairGenerator} instance.</p> | ||
* @return a "DSA" {@code KeyPairGenerator} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static KeyPairGenerator getDsaInstance() { | ||
return getInstance("DSA"); | ||
} | ||
|
||
/** | ||
* <p>Get a new "RSA" {@code KeyPairGenerator} instance.</p> | ||
* @return a "RSA" {@code KeyPairGenerator} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static KeyPairGenerator getRsaInstance() { | ||
return getInstance("RSA"); | ||
} | ||
|
||
/** | ||
* <p>Get a new {@code KeyPairGenerator} instance without throwing {@code NoSuchAlgorithmException}.</p> | ||
* @param algorithm the {@code KeyPairGenerator} algorithm | ||
* @return a {@code KeyPairGenerator} instance of the provided algorithm | ||
* @since 1.3.1 | ||
*/ | ||
private static KeyPairGenerator getInstance(final String algorithm) { | ||
try { | ||
return KeyPairGenerator.getInstance(algorithm); | ||
} catch (final NoSuchAlgorithmException e) { | ||
throw new AssertionError(e); | ||
} | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
src/main/java/com/github/alexisjehan/javanilla/crypto/StandardSignatures.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,92 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2018 Alexis Jehan | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
package com.github.alexisjehan.javanilla.crypto; | ||
|
||
import java.security.NoSuchAlgorithmException; | ||
import java.security.Signature; | ||
|
||
/** | ||
* <p>A {@link Signature} factory to get standard instances without throwing checked exceptions.</p> | ||
* @since 1.3.1 | ||
*/ | ||
public final class StandardSignatures { | ||
|
||
/** | ||
* <p>Constructor not available.</p> | ||
* @since 1.3.1 | ||
*/ | ||
private StandardSignatures() { | ||
// Not available | ||
} | ||
|
||
/** | ||
* <p>Get a new "SHA1withDSA" {@code Signature} instance.</p> | ||
* @return a "SHA1withDSA" {@code Signature} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static Signature getSha1WithDsaInstance() { | ||
return getInstance("SHA1withDSA"); | ||
} | ||
|
||
/** | ||
* <p>Get a new "SHA256withDSA" {@code Signature} instance.</p> | ||
* @return a "SHA256withDSA" {@code Signature} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static Signature getSha256WithDsaInstance() { | ||
return getInstance("SHA256withDSA"); | ||
} | ||
|
||
/** | ||
* <p>Get a new "SHA1withRSA" {@code Signature} instance.</p> | ||
* @return a "SHA1withRSA" {@code Signature} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static Signature getSha1WithRsaInstance() { | ||
return getInstance("SHA1withRSA"); | ||
} | ||
|
||
/** | ||
* <p>Get a new "SHA256withRSA" {@code Signature} instance.</p> | ||
* @return a "SHA256withRSA" {@code Signature} instance | ||
* @since 1.3.1 | ||
*/ | ||
public static Signature getSha256WithRsaInstance() { | ||
return getInstance("SHA256withRSA"); | ||
} | ||
|
||
/** | ||
* <p>Get a new {@code Signature} instance without throwing {@code NoSuchAlgorithmException}.</p> | ||
* @param algorithm the {@code Signature} algorithm | ||
* @return a {@code Signature} instance of the provided algorithm | ||
* @since 1.3.1 | ||
*/ | ||
private static Signature getInstance(final String algorithm) { | ||
try { | ||
return Signature.getInstance(algorithm); | ||
} catch (final NoSuchAlgorithmException e) { | ||
throw new AssertionError(e); | ||
} | ||
} | ||
} |
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.