Skip to content

Commit

Permalink
fix problems pointed out in review
Browse files Browse the repository at this point in the history
  • Loading branch information
stoty committed Nov 22, 2024
1 parent d88ff3d commit 1a1d524
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -128,13 +127,17 @@ public boolean isComplete() {
}

@Override
public byte[] unwrap(byte[] incoming, int offset, int len) {
throw new IllegalStateException("Mechanism does not support integrity nor confidentality");
public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException {
if (!isComplete())
throw new IllegalStateException("Authentication exchange has not completed");
throw new SaslException("OAUTHBEARER supports neither integrity nor privacy");
}

@Override
public byte[] wrap(byte[] outgoing, int offset, int len) {
throw new IllegalStateException("Mechanism does not support integrity nor confidentality");
public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException {
if (!isComplete())
throw new IllegalStateException("Authentication exchange has not completed");
throw new SaslException("OAUTHBEARER supports neither integrity nor privacy");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -131,17 +130,17 @@ public boolean isComplete() {
}

@Override
public byte[] unwrap(byte[] incoming, int offset, int len) {
public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException {
if (!complete)
throw new IllegalStateException("Authentication exchange has not completed");
return Arrays.copyOfRange(incoming, offset, offset + len);
throw new SaslException("OAUTHBEARER supports neither integrity nor privacy");
}

@Override
public byte[] wrap(byte[] outgoing, int offset, int len) {
public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException {
if (!complete)
throw new IllegalStateException("Authentication exchange has not completed");
return Arrays.copyOfRange(outgoing, offset, offset + len);
throw new SaslException("OAUTHBEARER supports neither integrity nor privacy");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -159,13 +158,17 @@ public boolean isComplete() {
}

@Override
public byte[] unwrap(byte[] incoming, int offset, int len) {
throw new IllegalStateException("Mechanism does not support integrity nor confidentality");
public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException {
if (!complete)
throw new IllegalStateException("Authentication exchange has not completed");
throw new SaslException("PLAIN supports neither integrity nor privacy");
}

@Override
public byte[] wrap(byte[] outgoing, int offset, int len) {
throw new IllegalStateException("Mechanism does not support integrity nor confidentality");
public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException {
if (!complete)
throw new IllegalStateException("Authentication exchange has not completed");
throw new SaslException("PLAIN supports neither integrity nor privacy");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,17 @@ public boolean isComplete() {
}

@Override
public byte[] unwrap[B(byte[] incoming, int offset, int len) {
throw new IllegalStateException("Mechanism does not support integrity nor confidentality");
public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException {
if (!isComplete())
throw new IllegalStateException("Authentication exchange has not completed");
throw new SaslException("SCRAM supports neither integrity nor privacy");
}

@Override
public byte[] wrap(byte[] outgoing, int offset, int len) {
throw new IllegalStateException("Mechanism does not support integrity nor confidentality");
public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException {
if (!isComplete())
throw new IllegalStateException("Authentication exchange has not completed");
throw new SaslException("SCRAM supports neither integrity nor privacy");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -202,13 +201,17 @@ public boolean isComplete() {
}

@Override
public byte[] unwrap(byte[] incoming, int offset, int len) {
throw new IllegalStateException("Mechanism does not support integrity nor confidentality");
public byte[] unwrap(byte[] incoming, int offset, int len) throws SaslException {
if (!isComplete())
throw new IllegalStateException("Authentication exchange has not completed");
throw new SaslException("SCRAM supports neither integrity nor privacy");
}

@Override
public byte[] wrap(byte[] outgoing, int offset, int len) {
throw new IllegalStateException("Mechanism does not support integrity nor confidentality");
public byte[] wrap(byte[] outgoing, int offset, int len) throws SaslException {
if (!isComplete())
throw new IllegalStateException("Authentication exchange has not completed");
throw new SaslException("SCRAM supports neither integrity nor privacy");
}

@Override
Expand Down

0 comments on commit 1a1d524

Please sign in to comment.