2014-09-04 11:04:51 +02:00
|
|
|
/**
|
|
|
|
*
|
2018-08-21 09:16:11 +02:00
|
|
|
* Copyright © 2014-2018 Florian Schmaus
|
2014-09-04 11:04:51 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
package org.jivesoftware.smack.util.stringencoder;
|
|
|
|
|
2015-01-26 20:36:55 +01:00
|
|
|
import org.jivesoftware.smack.util.Objects;
|
|
|
|
|
2014-09-04 11:04:51 +02:00
|
|
|
|
|
|
|
public class Base64UrlSafeEncoder {
|
2018-08-21 09:16:11 +02:00
|
|
|
private static StringEncoder<String> base64UrlSafeEncoder;
|
2014-09-04 11:04:51 +02:00
|
|
|
|
2018-08-21 09:16:11 +02:00
|
|
|
public static void setEncoder(StringEncoder<String> encoder) {
|
2015-01-26 20:36:55 +01:00
|
|
|
Objects.requireNonNull(encoder, "encoder must no be null");
|
2014-09-04 11:04:51 +02:00
|
|
|
base64UrlSafeEncoder = encoder;
|
|
|
|
}
|
|
|
|
|
2018-08-21 09:16:11 +02:00
|
|
|
public static StringEncoder<String> getStringEncoder() {
|
2014-09-04 11:04:51 +02:00
|
|
|
return base64UrlSafeEncoder;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final String encode(String string) {
|
|
|
|
return base64UrlSafeEncoder.encode(string);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final String decode(String string) {
|
|
|
|
return base64UrlSafeEncoder.decode(string);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|